Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Explosion Problems

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Jan 2016 23:32 Edited at: 7th Jan 2016 03:36
I am working on a kind of cross between gyrus and asteroids

Declaration


collision




but the code stays on the first frame until the sync command is used and I cant use sync due to the location
I probably need some good old math to align the explosion as I use offsets and rotation which seem to misplace
the overlayed explosion

here is the video in action



Update2d ?

I am also open to anyone with a good particle explosion I could use instead it would be appreciated as the present one may change
altogether?

I am at present using the gyro for movement was thinking touching the ship sprite to fire a bullet also not sure what you think?
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 7th Jan 2016 00:33 Edited at: 7th Jan 2016 00:50
all the positioning will be from the top left of the sprite so you are using the ships (x,y) to position the explosions(x,y)
unless the ships width, height, scale and rotation are exactly the same as the explosion's then it will be off
i attached an explosion animation. not the best but it might be ok

you might want to consider a state machine. state machines are just a fancy way of thinking about things in terms of what they are doing at any given time so in this case you might have something like this



in your code above you would just set ship_state to EXPLODING and then use the code i posted after the loop

Quote: "I am at present using the gyro for movement was thinking touching the ship sprite to fire a bullet also not sure what you think?"

i am writing a similar game atm and i think using the gyro and constantly firing is best (no touch to fire). i am going to add a bullet pickup so there is the possibility of running out of bullets
where you then have to shift into evasion mode. it adds a little to the game play i think

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Jan 2016 06:01
Quote: " but the code stays on the first frame until the sync command is used and I cant use sync due to the location"

Well that's what sync does, updates the screen. You could manually change the frames on your sprites and you still won't see it until you sync everything. Why are you calling update2D manually?

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Jan 2016 10:07
thanks BlinkOk the sprites were very useful I even tried making it a function and exiting the function with kinda dismal results lol but il get it


Phaelax
I was hoping the update2d command would stop the freeze on first frame
fubar
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jan 2016 11:13
Try this:
If GetSpriteCollision(Ship,Asteroids[number].SpriteID) AND (getspriteplaying(Explosion)=0)
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Jan 2016 11:43
Didn't think that was the issue CJB
but thanks you were right it kept starting the collision again
it wasn't a sync issue at all like I thought



that's the working code
fubar
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jan 2016 12:12 Edited at: 7th Jan 2016 12:12
Happy to help

btw: Great looking project! Can't wait to play
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
haliop_New
User Banned
Posted: 7th Jan 2016 18:42
please show a video of the working new explosion
I want to play this !!!
maybe add a little black hole In the middle and if you go too close you are getting sucked in
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 8th Jan 2016 01:37
Here's what I have so far

The missile obviously needs work as sometimes it over shoots the centre and isn't set up for asteroid explosions yet
I tried using a difference algorithm to determine whether the missile had made it to centre lol
at the moment I use an invisible black sprite which seems to do the trick but problems with the way
I use the offsets rotation and sprite movement means it still can overshoot the mark

Difference Algorithm I first tried


The Missile and Block in centre


I'm not sure what I was thinking with 3 states so much tidy up to do
but in the missile move function for collision it does the following. ATM (virtual resolution is setup as 1024 by 768)





I also need sounds, il see what I can create

But Haliop_New this is whats working atm
[video=youtube]https://youtu.be/FKy18MgVeYo[/video]

I am planning to have a timer countdown before you start playing and after each death so you have a chance to get ready

and it will warp you towards the centre at the end of each level just like gyrus


Lots to do as you can see
fubar
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jan 2016 06:25
Word of advice, use constants for your missile states. That way you always know what it means. For example:



Does nothing to improve performance, but it does improve your code readability. And trust me, one day you'll come back to this code and look at it and say "wtf does 0 mean?"

When you say it overshoots the center, are you referring the center of the asteroid? If it appears to overshoot, it could simply be how fast things are moving and that is just their next step before a collision is detected. Oh wait, I just looked up a video of gyrus and saw how it shoots towards the center of the screen, I think I know what you mean now. I'm willing to bet you're checking the missile's current position and not what it's next position is about to be. Thus it's moving to the center (and slightly beyond) before being removed from the playing field. When you update the missile's position, check if it's reached the center or a collision before calling sync. That way, it can be removed if needed before updating on the screen. Hope that made sense.


Btw, to use the youtube tags, you only need to use FKy18MgVeYo and not the whole address.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jan 2016 09:41
I put this together for you. I pulled the media from my asteroid game, so sorry in advance the asteroid animation isn't contained in a single file.
Hopefully, this can help you out and show you how helpful it can be keeping your code modular. It becomes easier to manage, not too mention your game loop looks cleaner:



Biggest difference between yours and mine is the collision. I didn't use sprite collision in my demo, I simply checked the proximity of the bullet to the asteroid based on distance between the two and the radius of the asteroid. Also, instead of the ship rotating in a circle, mine rotates around the screen in an elliptical manner. I've attached the whole project, it's about a 2.5mb zip download.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 8th Jan 2016 14:43
Thanks Phaelax but unfortunately the EXE wont run under windows 10 and I'm using AppGameKit and still yet to look at the code

I agree the code needs tidying allot I usually go over that after I get a piece of working code I find I get myself in an infinite loop otherwise
but I appreciate the input And going back to old code can be an issue especially if not documented and the thoughts of what was I doing then lol

I enjoy coding even if I don't put all that many man hours in and quite rusty, been coding in different languages for quite a while but after going to UNI
kinda went through I cant be bothered stage lol but hopefully now I get motivated again and start to use good programming practices again.

Here is the Latest Preview for those interested

[video=youtube]https://www.youtube.com/watch?v=2oJdqUfMGL4&feature=youtu.be[/video]
Has sound now and can have multiple explosions but only uses the 1 sound which seems to have the desired effect

Warp Stages etc to come
and still no idea what to call it lol
Gyrock was one thought but don't like it enough lol

fubar
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jan 2016 16:11
Your youtube tags are wrong... You only need to include the unique reference bit, not the whole URL:

V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jan 2016 18:19
Looking good.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 8th Jan 2016 18:35
Can it move a full 360 around the screen or only the lower half?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 8th Jan 2016 20:40
yes it can do a full 360 mrradd but I kinda get confused when I'm on top so I kept the demo without it
fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 10th Jan 2016 01:14
Ive encountered a problem when I tested on phone

everything works except now the animations don't display on my Samsung galaxy
I tried removing the stars didn't do anything except not display them lol
I even made another small program to test if animations work and yes they work fine on my phone
I tested the syntax and name of explosion.png as the phone seems quite fussy with name conventions but that didn't seem to help either

The Explosion Declarations


The code that don't seem to display the explosions just completely avoids it (PS the sound works just not the animation)

fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Jan 2016 05:39 Edited at: 10th Jan 2016 05:40
did you make sure the filenames match exactly? android filenames are case sensitive
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 10th Jan 2016 07:37
Sure did ? unfortunately wasn't that


but did change some code around now it shows as one frame for the explosion
The animation works perfectly well under windows
going to try and play around with frame speeds some more perhaps that's it or a syncing issue when run on phone
fubar
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 13th Jan 2016 16:19
fubarpk:

Your difference function can be simplified. Instead of using two value checks, just use the Abs function:

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 14th Jan 2016 04:30
[video=youtube]watch?v=c5NZwx84QJM&feature=youtu.be
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Jan 2016 04:36 Edited at: 14th Jan 2016 05:57
looking very nice! well done



this is how i embedded the video above;

Sign up for NaGaCreMo!

Login to post a reply

Server time is: 2024-11-17 02:23:22
Your offset time is: 2024-11-17 02:23:22