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 Discussion / shooting code

Author
Message
bgranger
14
Years of Service
User Offline
Joined: 22nd Nov 2009
Location:
Posted: 23rd Nov 2009 04:46
me and my friend are doing a project for a video game design class at school using dark basic. we are just starting the class but we have both have prior game program knowledge we just cant figure out how to make objects shoot using dark basic, anyone who knows any information on this please help.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Nov 2009 07:12
Welcome to the forums bgranger! In the future, try to keep from double posting.

For the shooting, there are some options. Is this an object that the player will be able to see, such as a cannon ball, energy ball, or missle? Or is it a bullet or other object that the player cannot see.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 23rd Nov 2009 10:41
Have you tried the monster hunt tutorials? They're pretty useful if you're just starting out and you want to make this sort of thing. "The shooting code" will change from program to program, but it should give you a basic idea of what you want to do and why you want to do it.

http://developer.thegamecreators.com/?f=t01/3d_tutorial_index

bgranger
14
Years of Service
User Offline
Joined: 22nd Nov 2009
Location:
Posted: 24th Nov 2009 03:08
thank you. and i am sorry for double posting its my first post and didnt know it would be reviews first i thought something happened with my internet or something. the object will most likly be just a sphere that we will texture to look like an object related to the game, its not that advnaced, its a project for a design class at school and we are just messing around with other ideas after we finished it. we both downloaded dark basic profesoinal and are working on other codes at home to.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 24th Nov 2009 03:29
2d or 3d?

in 2d, if you aren't going to be rotating your shooter then it's just a simple change the x or y position of the bullet and then check for collision(well same in 3d, exept you have to change the z also)

if it's 2d and you are rotating the shooter then you need to use sin and cos and trig stuff the find the movement of x and y then reposition it.

for 3d it's quite simple. rotate the bullet how you want, then just use Move Object command and it will move straight forward(at whatever and it is at) then just check for collision.

New Site! Check it out \/
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 24th Nov 2009 04:15
Like Caleb says, if rotation is not an issue, it should be reasonably easy to achieve. The moment you start including different angles, solutions become more varied and may rely on more different conditions of what you want to do. Give an example of your code and maybe you'll be able to find a more accurate source.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 24th Nov 2009 05:05
For a game like Solar Striker(idk if anyone knows that game) here is the basic idea:

You can move up and down the screen and the enemies come off the top and come down at your. All the bullets go straight up the screen. No angles or anything. So all you need to do is take away from the y position and then check for collision.

but take a game like Asteroids for example. in that game enemies come from all around and you rotate. well to find out how much x and y to add you would need to calculate the movement based on the angle of rotation. like this:

moveX = sin(angle)*speed
moveY = (cos(angle)*-1)*speed

I did cos(angle) times -1 because the y axis is opposite(+ is down and - is up) then you add that to your x and y values and you get a nice smooth movement at that specific angle.

New Site! Check it out \/

Login to post a reply

Server time is: 2024-03-29 06:18:20
Your offset time is: 2024-03-29 06:18:20