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 / Getting enemy sprites to move and shoot projectiles by themselves

Author
Message
Darkwatch67
14
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 1st Mar 2012 17:32
Hello.

I am writing a program for a top down 2D space shooter. I have figured out most of the basics of the game, I can move my ship and shoot a laser which will destroy enemy ships on screen. This will delete the enemy sprite and add points to the player's score.

The problem is that I can't get the enemy ships to mvoe by themselves on a set path across the screen. At the moment, all they do is stay in the same place. I can get them to move in one direction only, but even then they don't disappear when shot since the image is still getting loaded in.

I also need help getting the enemy ships to shoot their own laser at random times, but I have no idea how to implement this.

Here is my code at the moment:



So to sum up, how can I get the enemy ship sprites to move both ways in the X axis on it's own accord and to disappear when it comes into contact with the player laser? Also, how do I implement enemy sprites shooting lasers at random or specific times?

Thanks for all help in advance guys.
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 1st Mar 2012 19:01
one suggestion: (that might solve you all the problems)
use arrays, read about them a little. how arrays works and how you use them, then use them for your enemies.

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
Darkwatch67
14
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 1st Mar 2012 19:59
I've used arrays in programs before, but unfortunately I'm not sure how they would work in this case. Would I store the enemy movement/shooting commands in the array? Were that the case, I'm still not sure how I would implement that.
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 1st Mar 2012 21:21


try that code out.
as u can see, all the circles moves in the screen randomally.
you also can adjust the total_enemies to how many you want.


i tryed to make it the simplest so you could understand how the AI works. enjoy!

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]

Login to post a reply

Server time is: 2026-07-10 10:20:19
Your offset time is: 2026-07-10 10:20:19