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 / Aiming and making a bullet go where you click?

Author
Message
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 9th May 2009 05:54
I am trying to make a bullet that comes from my plane (or circle ) follow where you clicked the mouse. I am not sure what to do on this as I have never done this before. What would be the appropriate code for that? Here is my current code,



Remember, I have to have it follow where you clicked, not just go to it. Can I have some pointers/code to help me with this?


.:Cheers:.
~!Zeus!~
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 9th May 2009 18:42
Umm, anyone?
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th May 2009 18:44
ummmmm, code?

generally we need the entire code to help, post that and maybe someone will help

There are only 10 kinds of people in the world, those who understand binary and those who dont
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 9th May 2009 21:17
That is the entire code...
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th May 2009 22:28
no i mean put the whole program, not just the section ur questioning

There are only 10 kinds of people in the world, those who understand binary and those who dont
Yodaman Jer
User Banned
Posted: 9th May 2009 22:39
Well, you probably have it setup like this...tell me if I'm wrong though!



That's how I'd have it setup anyway...I know that doesn't answer any of your questions and I apologize for that, but is that how your code works?

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 9th May 2009 23:48 Edited at: 9th May 2009 23:49


An example program displaying how i would approach this.

Thanks, Stefan
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th May 2009 17:05
Not very accurate but here's a simple method...


Riddle: The more you take, the more you leave behind. What are they? Answer
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 10th May 2009 17:43
You spelt position wrong for camera Y position. What if Zeus wanted 2d

Thanks, Stefan
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th May 2009 00:32
@Stefan P
good spot. Did it work other than that? I had to type it all in.
Your code was 2D so he has that if he wants but I noticed he mentioned planes in the original post so I interpretted that as 3D.

Riddle: The more you take, the more you leave behind. What are they? Answer
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 11th May 2009 00:48
@OBese87

Yea everything worked. I just tested now. I just was looking over the code to see how you did it.

Thanks, Stefan
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th May 2009 00:57
I've been a bit cheap though because I haven't included rotating the camera. You'd need some maths to adjust the angles and incorporate z angle.
but if you're going to do that you might as well write something better than my one

Riddle: The more you take, the more you leave behind. What are they? Answer
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 11th May 2009 05:18 Edited at: 11th May 2009 05:19
Thanks guys.

@Yodaman Jer: Yeah, that is how I have it setup exactly.

@OBese: By plane I meant airplane. Haha.
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 11th May 2009 18:04
Well, this isn't working at all, here is my first attempt at it.

(Entire Code)


This didn't do anything except flash a circle where bulletx and bullety are and disappear.


My 2nd attempt,


That just moved the bullet the complete opposite of where I clicked the mouse. Perhaps I wasn't clear enough so what I want is the bullet to go to where you click the mouse. You know aim and fire?


.:Thanks:.
Zeus
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 12th May 2009 05:08
Anyone?

<a href='http://callofduty.myfabforum.org/'><img src='http://callofduty.myfabforum.org/images/userbar2.png'></a>
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th May 2009 15:28
man knock the double posts off, especially for pointless stuff like that

There are only 10 kinds of people in the world, those who understand binary and those who dont
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th May 2009 15:31
If it's just going the wrong direction don't you think there could be a very simple change to make it work. Try to think a bit more positive.

You should never have a DO loop inside a subroutine. Subroutines want to go back to the main loop and they can't do that if they get stuck in a DO loop.

Your program is pretty much there though, just cut the loop out and paste it above the subroutine, this is now the main loop. Then put a gosub before the main loop calling the Game_level1 subroutine.

Riddle: The more you take, the more you leave behind. What are they? Answer
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th May 2009 18:55
your problem in the first one is here:



it only does that if shooting = 0 and when you hit the mouse shooting is = 1. which is fine but your Gosub _Shooting part is in that. so it's only executed when shooting is equal to 0 and mouseclikc = 1 see?

since you already have a check for shootings equality to 1 in your shooting subroutine then just put the Gosub _Shooting outside of that if. like this:



that should work

New Site! Check it out \/
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 13th May 2009 00:02
Please guys compile this code, it isn't working right at all. I do not know what I am doing wrong. Please correct me where I am wrong.



The bullet does not go where you click the mouse! You guys are aware of the fact that is all I am asking for right?

<a href='http://callofduty.myfabforum.org/'><img src='http://callofduty.myfabforum.org/images/userbar2.png'></a>
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th May 2009 02:14
@Zeus
You need to go through TDK's tutorials or something. There are a lot of errors in your code.

1. As I said earlier, the do loop should be above all subroutines and the routines should be called from within the loop.
2. You don't set the bullet position when firing, only at the beginning of the program, which is pretty useless.
3. You've written the bullet move code so the bullet is always moving up and to the left.

I'll help you with point 3 as this is what you are repeatedly asking for...

What you're essentially doing is drawing a line.
First we need to find the length of the line by constructing a triangle from the co-ordinates of our two points (a and b).

...
Sorry I'm stopping here because I want to work on my dbc challenge entry. I've written the code but I'd have to type it out again which I'm too lazy to do. I'll upload for you when I go to the library.
Deceptively tricky program though.

Riddle: The more you take, the more you leave behind. What are they? Answer
Zeus
19
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 13th May 2009 16:33
Thank you OBese87, sorry to bother you all. I haven't used DB for a while now and I guess I just need to be refreshed. I will take a look back on TDK's tutorials again.

<a href='http://callofduty.myfabforum.org/'><img src='http://callofduty.myfabforum.org/images/userbar2.png'></a>

Login to post a reply

Server time is: 2025-08-08 20:38:23
Your offset time is: 2025-08-08 20:38:23