Space invaders. Random alien shot. How to?

For questions about using Classic.

Post » Tue Jan 26, 2010 11:25 am

I'm trying to make a Space Invaders game but I'm stuck already :)

How would I go about randomly assigning an invader to fire and positioning the bullet at that ship? I can't find anything on random numbers etc.

Thanks.
B
2
G
2
Posts: 12
Reputation: 674

Post » Tue Jan 26, 2010 11:42 am

Scrub that, I found it. Everything is in there if you search for it. Just a bit confusing for a newbie. :D
B
2
G
2
Posts: 12
Reputation: 674

Post » Tue Jan 26, 2010 11:55 am

Perhaps you could post your solution in case anyone else searches/reads this post - I suppose you used a 'pick random' condition followed by 'spawn an object'?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Jan 28, 2010 12:34 pm

Ye sorry.

I use the SPRITE - PICK ONE AT RANDOM event. Then set that to spawn a bullet, which was set to fire down the screen (in the bullet options). The problem was, it fired all the time. So I also added a RANDOM condition to the event so that it didn't. I found that getting it to choose a number between 1 and 100 and allowing it to fire if it picked 50. You can add a condition to an event just by clicking on it when you've created it, a popout appears allowing you to set it.

This is how it looked in Construct Event panel.



Great peace of software BTW. I'm lucky enough to be able to search through the options and commands but I imagine there's loads I'm missing. Hoping to help with the Wiki if I become comfortable enough to pass on my knowledge.
B
2
G
2
Posts: 12
Reputation: 674

Post » Thu Jan 28, 2010 1:46 pm

It might be better to use 'every X milliseconds' with a random interval, or even a constant interval (eg. every 500 ms). The way you've done it there it chooses a random number every frame. So if someone's computer is slow and running at half the framerate, the enemies fire half as often, but would keep moving at the same speed (see TimeDelta).

This is another reason to post your own answer: you might not have done the best thing! :)
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Jan 28, 2010 3:31 pm

Makes sense. :)

Cheers, I'll try it your way. Tend to forget that people still have slow comps. Most now can run games like this easily.
B
2
G
2
Posts: 12
Reputation: 674

Post » Thu Jan 28, 2010 3:43 pm

That's true, but it's not the only issue. Take a look at that article. Basically the way you've done it changes speed depending on the framerate, and it shouldn't. If you v-sync your game (which makes it look smoother), one PC may run the game at 60fps for a 60Hz monitor, and another at 120fps for a 120hz monitor. The guy with the higher refresh rate would have a much harder game, your way, because enemies fire twice as often!
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests