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.

Newcomers DBPro Corner / AI (space invaders)

Author
Message
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 30th Jan 2004 22:01
how can make my enemy ships in my space invaders only fire if they are on the bottom line and make each one have a certian amount of time until they fire? here's my code

just code
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 30th Jan 2004 22:20 Edited at: 30th Jan 2004 22:21
If you enemy ships are arrranged in rows of colums it isn't too difficult.
In my game I had two vairables, on was the timer() value when the enemy last fired(last_fire) and another is the delay between shots(fire_rate) in milliseconds.

Then somewhere in the main loop
if timer() - last_fire > fire_rate
enemy_fire()
last_fire = timer()
endif

Then the enemy_fire function/sub routine in psudo code
make sure there is more than one enemy ship then
repeatedly randomly select a column until you find one with an enemy ship in.
Then check from the bottom of the column to the top to find the lowest enemy ship and fire from that ship.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 30th Jan 2004 23:13 Edited at: 31st Jan 2004 02:28
in my space invaders I just did the lazy thing an had any valid baddie shooting. If he wasn't on the bottom row it didn't matter because the bullet collision only worried about colliding with the barriers and/or the player objects. I don't rightly remember, but wasn't the coin-op version that way as well? Anyway, my version was lame because I never finished the baddie-walk routines, they were kinda retarded-stationary-badie-shooty-thingys as you can see below...





-RUST-
"What the... Mooooooooooo!"
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 30th Jan 2004 23:37
could you give me some code that would say weather the ship is on the bottom row and get the delay time to ramdomly select a value so that it does not fire in a regular pattern. how would i maake the rnd command select a number between to values say 8000 and 20000 so that the ship only fires in between those values?

just code
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 31st Jan 2004 02:10
what if you made a rnd() function return only the numbers that correlate to the actual baddie object numbers(x to max_baddie), then test to see if a)that object number exists(hasn't been already shot) if so, if that baddie is in the bottom row, which you could determine by the baddie's position in space since you have to keep track of the baddies movements as a group to know when to stop going left drop down, go right, stop going right, drop down, go left,....

-RUST-
"What the... Mooooooooooo!"
Jonny_S
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 31st Jan 2004 02:12
Why dont you just hide the bullet if it is colliding with enemy ships, then select any random object/sprite to fire the bullet, thats what i did

Supermonkey - The crime gifhting sex god monkey!
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 31st Jan 2004 10:37
what is code for checking to see if the sprite is on the bottom row?

just code
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 31st Jan 2004 18:41
Quote: "what is code for checking to see if the sprite is on the bottom row?"


Too many variables, I'm afraid you'll have to figure that one out yourself. Here are a few clues... The 'bottom' depends on the size of your sprites, the size of the screen, how you organize your sprites, the height of your barriers (if any), and the range you want them to shoot at. All that boils down to a single number, most likely a screen Y value where if the sprite is below this mark it can fire.
--
TAZ

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 1st Feb 2004 00:42
It depends how your enemy sprite number are organised.

Mine are


And the alien fire function is

Login to post a reply

Server time is: 2024-11-26 03:35:46
Your offset time is: 2024-11-26 03:35:46