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.

2D All the way! / having issues controlling my bullets in 2d! among other things...

Years of Service
User Offline
Joined: 15th Oct 2009
Posted: 12th Mar 2010 16:11 Edited at: 12th Mar 2010 16:45
hello there
for my college project im making a 2D game in darkbasic classic. i have my movements and map ready i just cant seem to control the bullets.

they travel for so long and then loop, so my character looks like he has mind bullets. here is my code which keeps looping:

and heres another code i am trying, which is quite inefficient in my game as the closer the character is the more bullets they can fire:

Also im having issues with loading an AVI as an intro, is it the codec not being IR45 and i have tried cinepak.

oh yeh just looking for a push in the right direction, no spoon feeding please, i wont learn that way.

thank you
Retired Moderator
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Mar 2010 16:46
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 20th Mar 2010 01:19
You can use basic trig to move your bullets. First find the angle of the bullets and find the X and Y distance between where your aiming and where the bullets start. Then just rotate the bullet that angle and move it.

If it hasn't exploded yet, I haven't touched it.
Dark Dragon
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 9th Apr 2010 17:11
Thats Pro code.
He needed Classic.

(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Apr 2010 20:18
You should have posted this on the DBC board as not many people here use DBC.
Maybe a MOD will be kind enough to move it.

You check if sprite 10 exists twice unnecessarily. I think just deleting the bullet sprite will solve your problem, providing you have a firing routine that creates it.
I think this subroutine is a bit odd because its purpose is to move the bullet but the first thing it does is to check if the bullet exists, I think that check should be outside the subroutine as there are other subroutines that also work with the bullet and they would have to check if it exists too, which is a lot of repeated code.

Personally if I have a condition like "If BulletLife < MaxLife" where I am checking a variable that I will change if it meets the condition, I put the variable change first inside the condition. That is purely personal preference but I think it shows the ultimate purpose of the condition, if you put it at the end you have to remember that it is BulletLife that you checked in the first place.

Login to post a reply

Server time is: 2023-02-04 21:10:14
Your offset time is: 2023-02-04 21:10:14