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 / Getting a box to shoot spheres in the direction the player specifies?

Author
Message
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 20th Sep 2004 10:46
Okay Major,

I have examined the code and made the corrections as needed... though I note that the selection code still confuses the heck out of you. You had three entire selection processes going on which was never needed, but I did note that in dragging an object and hitting another one, it dropped the object I was moving and moved the other instead! (Ack!)

So, I have reduced and changed the selection process to be both minimal and selecting properly, please don't try adding to it by duplicating the routine again, just add in the if statements for the numbers of objects you're allowed to move. (You'll see what I mean when you read it over.)

And yes, the object collsion(x,y) is the source of the error, such that I have remmed out those lines and shown how to do it using object collision(x,0). This code does NOT presently detect against the bullets being fired by the machine nest, but I would suggest that this only occurrs after the waves begin moving. (An easy change.)

Oh yes, since I used 16 bit depth I lightened the colors a little on the nest and its target, so I could see them for placing. And I upped the timeleft() by a factor of ten, for I think my machine runs a little bit faster than yours.

Good luck, code under source...
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 20th Sep 2004 11:07
Rats! I thought I was done but now I have some additional comments...

You mentioned in this thread that some of the red squares are deleting each other when the collide, particularly when path-finding around the barriers. That is obvious given the the detection of;



Because you also testing verses the object numbers of 6 through 15 by the "k > 0 and k < 20." While the original I posted does work providing that the horizontal positions of the red boxes does not change (relative to each other since they are placed to not be colliding when created,) if they move side-to-side the if statement will be more complex as in;



because you have to avoid testing the enemy against itself. This is why I told you the object numbers needed to be changed, such that say, objects 1 to 300 are for the player to move around, 400 to 600 are enemy, 1000 and up are bullets, and so on. In that case opject number 8000 say would be the selection box, to give yourself room to make the tests easier. If you did this, the selection code would be easier too, instead of;



it would become;


Takes a bit of time to change the numbers I know, but I think you'd be happier with the result...

Take Care & Good Luck!
S.

Any truly great code should be indisguishable from magic.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 20th Sep 2004 11:16
Sandrad, you just saved the day! The little red dudes now move around the object, although I was wondering if it was possible to make them move randomly left or right, but it works just as good now. I will take your advice, and attemp to re-arrange all the object for easier coding. Thanks!

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 20th Sep 2004 13:56 Edited at: 20th Sep 2004 13:57
Sure, that's easy to do... What I'd suggest is something like this;



This way, when they hit the baracades, they select either a left or right direction to go, then keep going in that direction until they stop colliding.

ttfn!
S.

Any truly great code should be indisguishable from magic.
Dot Merix
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 20th Sep 2004 14:27
Ahhhh crap.. i had a feeling it had something to do with that code..


Guess i was just too blind to see it, thanks for helping him out Sandra

- Merix

WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 20th Sep 2004 19:04
No prob, Merix.. I'm happy to help.

And OOPS! I realize my selector code there had an error.. here's how it should be;



Trouble was, it'd keep setting the mover value back to -5...
(gotta remember to test conditions individually...)
S.

Any truly great code should be indisguishable from magic.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 21st Sep 2004 09:21
I began the long task of re-numbering all the objects, and jeez am I in a pickle, oh well, I will have to try some more, so many objects, in so many places!

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.

Login to post a reply

Server time is: 2025-05-24 17:54:56
Your offset time is: 2025-05-24 17:54:56