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.

DarkBASIC Professional Discussion / How to make Space Invaders MoveRight,Drop,MoveLeft Etc

Author
Message
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 14th Jun 2011 14:04 Edited at: 14th Jun 2011 14:31
Hey Me and my mate are trying to make space invaders and while we have everything basicaly done so far except the win/lose triggers and Ai shooting back.We have no Idea how to get the ai to move drop and move left. If Anyone would help it would be greatly appreciated

Main:


Functions:


Space:


Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
SJPro
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 14th Jun 2011 18:35
There are many ways of the approaching the movement.

For one simple method you could have a counter variable for your game which is incremented each loop. Each loop you move your AI left by an amount. Once the counter hits a certain number you then change the height position of your AI reset the counter and each loop move you AI right etc. In this example you would need a variable to hold which direction they are moving which you "flip" when the counter reaches your desired amount. This is only example of how it could be done. the best method depends on how you want to design your game.

A quick comment on your code so far. It is best if you don't repeat similar line such as:



and



If you stored your AI data in an array and used a for loop to count through the index you would only have to write your code once. The advantage to this is you don't have to recreate your code 43 times, but more importantly if you make a change to the code at a later date the change only has to be made once instead of 43 time.

www.freewarehub.net
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 15th Jun 2011 18:22
Thanks yeah I only learned about arrays after i was late into this project lol

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee

Login to post a reply

Server time is: 2026-07-10 22:54:47
Your offset time is: 2026-07-10 22:54:47