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 / Targeting and multiple bullet problem

Author
Message
Programador hispano
18
Years of Service
User Offline
Joined: 11th Jul 2006
Location: Dallas, TX
Posted: 25th Aug 2006 08:16
Hello:
I am controlling 2 bullets with the mouse, one with the leftclick and the second one with the rightclick, and the target around the matrix with the mouse.

My big problem with the targeting system is that I want to shoot the first bullet at the target then have it go into a straight line towards the target, then move the target and not have the first bullet follow the target around when I re-target and shoot the second one, otherwise I have 2 bullets following the target around. Of course I want the bullets to come back to me. And I also have a small problem that when the bullets return, sometimes they just desapair.

This is my code so far..



Can somebody help me please.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Aug 2006 10:35
Hello,

Where ever the target is at any given time, it should have a position in terms of x,y and z. You will want to capture this position in some variables. It would be sort of a snapshot of the targets position.

For example, if you had variables x#, y#, and z# as the target's current position, then when say the left mousebutton is clicked, you take a snapshot of those values by assigning them to say snapshotx# , snapshoty#, snapshotz#.

Once you take the snapshot, you send your bullet to the snapshot coordinates, not to the target coordinates.

I would recommend dividing your program into functions and procedures. You can call these from your main loop. It can get messy coding everything in the main loop. Also don't be afraid to indent and separate blocks of commands with a blank line in between. It's very hard to read code that runs all together - and it will be easier for you to manage as well.

I suggest you create a new version where you completely remove the bullet 2 code. I think you should setup the bullet 1 code as a procedure, and take it out of the main loop. Get your bullet 1 code working 100%, and be able to call the procedure from within your main loop. once you get that working, do the same thing with your bullet 2 code.

here's an example layout - you can have functions and procedures. I just listed calling procedures. This is just a quick mark up of one posible layout:



Enjoy your day.

Login to post a reply

Server time is: 2025-05-25 21:56:58
Your offset time is: 2025-05-25 21:56:58