Help - Physics Space Ship Demo Need Help with picking object

Post your own tutorials, guides and demos.

Post » Sun May 31, 2009 11:27 pm

Hello all,
I am building a simple Space Ship / Asteroid shootem up Demo to help me learn the Physics behavior. But I have run in to a problem. The Big Asteroids are not being killed off like they should. The Asteroids have ID and Damage Private variables. In the game when a Big Asteroid gets 100 Damage it is killed and 3 smaller Asteroids replace it. But it is not working right. In debug I see the Damage goes above 100 but does not kill the big Asteroid.

So if anyone can take a look and see whats wrong with it. I know it must be something simple I missed with picking a object.

Use the arrow keys to move ship
Use spacebar to shoot
Made with Costruct Ver 0.98.9

[url:zepbf0sh]http://dl.getdropbox.com/u/1244375/SpaceShipDemo3.cap[/url:zepbf0sh]

edit to add file.. It was a little to big to upload here.
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Jun 01, 2009 1:55 am

You don't need to ID the asteroids at all.

And you're using a System compare to compare the asteroid damage value. The system doesn't know which asteroid you mean, so it's picking the first one, and watching that one. When that one goes kablooey, all the asteroids are destroyed because you don't have a sprite picked.

Use the asteroid sprite's own Compare Private Variable condition to check whether it's own damage is equal or greater to 100, and it works just fine.

You also need to "Remember picked objects" when you spawn your small asteroids with a function, so Construct knows which big asteroid to spawn from. Otherwise, when you kill asteroid 2, 3, or 4 then asteroid 1 will spawn the small asteroids because Construct can't remember which asteroid it was working with.

Also, you should check out the Custom collision mask for the astroids... with physics behavior you can draw a polygon around them to define a mask.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Jun 01, 2009 2:01 am

I think your over complicating your code. Also, to pick objects by value comparison, store the value in a private variable because System compare doesn't pick objects.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Mon Jun 01, 2009 2:02 am

Thanks deadeye for the tips. Ill give them a try and see how it goes.
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Jun 01, 2009 2:43 am

Yep deadeye your tips were right on target:)
The System compare was my problem. I knew it was something simple I was missing.

And thanks Davioware, now that I know that the System compare was my problem. I took out the extra code I put in tp track down the problem.

[url:3jhuiet3]http://dl.getdropbox.com/u/1244375/SpaceShipDemo4.cap[/url:3jhuiet3]

And if you or anyone else see anything else that could streamline the code let me know. Thats why I am doing this little demo project to learn how to code better in Constuct. And if you know any tips or tricks I like to see them.
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Jun 01, 2009 2:50 am

[quote="deadeye":17erg01n]
Also, you should check out the Custom collision mask for the astroids... with physics behavior you can draw a polygon around them to define a mask.[/quote:17erg01n]

deadeye I can see that with something that stays the same size. but I am randomly changing the small astroids size. How would that work?
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Jun 01, 2009 3:05 am

I dunno. Maybe you could make a few different types of small asteroids and spawn random ones.

It'd probably look better than stretching them, too.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Jun 01, 2009 9:59 pm

Nice demo, but something is fishing up the keys
B
2
S
1
G
5
Posts: 79
Reputation: 1,558

Post » Tue Jun 02, 2009 2:08 am

[quote="andla":3kcv0mxe]something is fishing up the keys[/quote:3kcv0mxe]
luigi's hands?
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Jun 02, 2009 12:57 pm

[quote="andla":afltl7uw]Nice demo, but something is fishing up the keys[/quote:afltl7uw]

Thanks andla,

Yes this little demo is far from done. I just got the basic engine done now. I have to get the HUD redone, right now it is set up for testing.
Get the scoring going and add lot more stuff to blow up :)
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests