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 / My last attempt, at getting an answer about this collision problem.

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Sep 2004 08:11
Several weeks ago I posted a question about a collision problem I was having with my game, my idea was to make the advancing enemy cubes dissapear when they touched one of the objects placed by the playe, but the collision would not work. After posting that question, I got no satisfactory answeres, thus I had no idea what to do next, my project never moved an inch from that moment, but now as I begin trying to learn C++, I want to complete at least one project in DBC, but it seems as though these forums dont want to help me, like people purposly pass my questions up, maybe thats not the case, but I need my question aswered.

Here is my code....



The collision code is in there, but its not working, the enemy cubes are not dissapearing when they touch the green "death cubes", please, please, tell me whats wrong, I would appreciate it.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 11th Sep 2004 08:18
We are not passing your questions up, it takes awhile to do stuff like this.I didn't see any code that deleted a cube once it had beeen hit. maybe that's the problem. C++ eh. I heard thats supposed to be a little confusing. Anyway let me know if that helps if not i'll try to formulate something.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Sep 2004 08:26
Well Im not deleting it, my code is just supposed to hide it, but thats not working.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 11th Sep 2004 08:29
That was just a suggestion. If you have 2 waves coming, what's the use of hiding the ones that have been hit. Unless there is something that I'm not seeing. Like I sain, try it and let me know if it works or not.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Sep 2004 08:34
I replaced the "hide object e" command with "delete object e" and got no new result. I just dont understand why it wont work, at first I thought maybe one was higher than the other thus they wouldnt collide with one another, but every object is set to 0 on the y axis.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 11th Sep 2004 08:41
Well, I haven't figured it out yet. Sorry. I haven't been doing as good as i usually do with coding. Maybe is someone else posts they can help. I'l keep on trying.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Sep 2004 10:22
Well thanks for the effort.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 11th Sep 2004 11:35
Your welcome and if you have any questions i.e. Have you figured it out yet? Just send me an e-mail.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Sep 2004 12:02
Nope, Im still trying to figure it out, but sense I have tried everything within my knwoledge, I dont have any more ideas.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th Sep 2004 19:02 Edited at: 11th Sep 2004 19:11
follow this rule for programs

setup

beginloop

gosub/functions

endloop

functions

gosubs


your code had placed the gosub "selection" smack in the middle of the main loop, I moved it too the end of the code (and removed the variable(0) bit because it is not needed in this case).
wave 1 hits the mines and gets killed, you have to delete them or place them at adistant location, if you just hide them then they still have collision and will kill the player, wave 2 does not respond to the minefield since you didn`t code the collision checks for the objects, heres the tweaked code.



you might like to adjust the random positioning of the blue objects so that they don`t intersect, to do that use a repeat until loop to check for object collision at the random position and then keep repositioning them until they don`t collide...eg:

repeat
position object x,rnd(100),0,rnd(100)
until object collision (x,0)=0

will keep positioning the object until it is not in collision with anything, hope thats some help.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 12th Sep 2004 02:11
Hey thanks, but I still have a prolem, I can no longer move the green cubes, and the collision only seems to work once, only one enemy actually died after that the collision seemed to lose all effect and no other objects would dissapear.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 13th Sep 2004 02:14
Just get "Nuclear Glory" for $15!!!

It solves all collision problems!
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 13th Sep 2004 02:56 Edited at: 13th Sep 2004 02:57
you know, why is it that that comes up everytime someone has a collision question? I know nuclear glory has there collision system, and I also know that I dont want to pay for anything, I also know that this problem can be solved if somone would take the time to help me.

jeez, I dont even know why I keep coming to these forums.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 13th Sep 2004 03:36
I tried figuring out collision in Db and got nowhere. If you don't got NGlory your really missing out, anyway I hope you get the help you're looking for(Sorry I can't help!)
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 13th Sep 2004 04:19
This isnt really that hard of collision, Im not trying to program in sliding collison or anything, I just want the stupid boxes to dissapear if they touch something.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 13th Sep 2004 05:00
I didn`t delve too deep into your code since it was way more complex than it needs to be for the job it does, I am in a project at the moment and want to be concentrating on that, basicaly, your code works so far on my system, the green blocks get erased by the attacking objects in wave one, you can`t move the objects any more like you said, but that is because the subroutine was moved to it`s proper place outside the loop.
Like I say, the green objects all get deleted here when they are hit, pick for the other objects is not working, I may scare up some code to do the same thing in a while when I get tired of my current WIP and need a break, I suggest you rewrite the code to get a fresh aspect on what it`s doing, if I have problems with something not working correctly then I rewrite it from scratch, that usualy gets me to spot what I did wrong the first time around .
hard though it may be to hear, your code will be the problem, if you write in a more modular manner (gosubs or functions to do different things for example), then you can find it a big help when debugging, you can blank off functions/gosubs with a rem and see what happens it allows you to simplify your code and see the problems without distractions, hope thats some help, I suspect most people are avoiding the code because it`s a bit messy and convoluted, simplifying the code would probably get more response.
remember, it`s no use blameing the machine or the compiler, they work fine for other people, like engineering, it`s the fault you put on yourself thats the hardest to find (after all ... you don`t make obvious mistakes ... right?)

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 13th Sep 2004 08:02
Well Im not trying to erase the green blocks, Im trying to erase the red ones with the green ones , and I dont even know much of whats going on in this code, alot of it was done by aura, and I just modefied it alot to get to where Im at right now. I would simplifi it, but I just dont know how.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 13th Sep 2004 08:07
Very well put mentor. The most obvious mistakes to others may not be so obvious to the person who originally coded it.

[url=www.angelfire.com/dragon2/dragonsinc/index.html][img]c:\temp\web_templates\DragonGames.bmp[/img][/url]

Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 13th Sep 2004 08:09
can somebody tell me how to simplify this code? I know that the object selection bit is way longer than it should be.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Balid
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 13th Sep 2004 13:18
Major Payn,

May be after you've learned C++ then you can figure out how to simplify the code. And coding in C++ is a lot more complex then DB.

If you don't understand the code that you ripped, what makes you think that you'll understand more advanced code? (More advanced does not mean more complex) Using someone elses code is fine, but if you don't understand it, don't come crying that no one helps when you change it and it does do what you want.

The "Do it for me" approach only makes you more dependent on others and you will never get anything you want done. Break down the code, copy a line of code and change it little to see what happens.

Rants over .

Read!!! & Slow down. Your not stupid. It takes time.

I also feel that you own Mentor a thank you for the work that he put in to YOUR code.
Quote: "Well Im not trying to erase the green blocks, Im trying to erase the red ones with the green ones "
Is not even close. Your explaination was a bit lacking and if you study his changes I know you can find the answer to your problem.

OK, may be now the rant is over

Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 14th Sep 2004 07:30 Edited at: 14th Sep 2004 07:33
It become pretty obviouse to me that Im never going to get the hange of Dark basic, dont be surprised if I never post here again. So thanks everybody for helping me learn atleast a little, I really wanted to learn this stuff, but it looks like that wont happen.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 14th Sep 2004 10:50
You have to remeber that it takes time to learn this stuff. Look at how long it has taken a lot of people to make their first game. If you give up, then , no you will never get the hang of it. So what i am saying is keep going on with it and see where you get.

Visit the Dragon Games homepage @ www.angelfire.com/dragon2/dragonsinc/index.html
or go to the forums @ http://djblackdragon.proboards3.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 15th Sep 2004 06:13
Okay, I have taken a few moments to look at this code, and to test the various operations for the problem suggested. First of course, I had to move the selection subroutine out of the main loop, then join the two halves of it back together for testing. (I assumeyou cut it in half for your own tests.)

Anyway, what I found is that there may indeed be an error of some kind within the object collision(x,y) code, such that you'll have to use object collision(x,0) instead. At least in that form the process does indeed operate, allowing multiple collisions to be detected properly.

And I should point out, your collision detection routine as written does NOT detect against wave 2, but that's niether here or nor there given the current problem. (I suggest you re-order your object numbers so that waves 1 and 2 are "side-bye-side" in object numbers.)

Anyway, here the code I've been testing, including a function to actively print the locations and colliding values for each active object.

Perhaps this will help ya...
S.

Oh yes, I changed all object collisions to boxes as well...

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: 15th Sep 2004 07:08
Thanks SandraD Its working like it should be now! This was the problem I needed to overcome, now that I can see how you got it working, I can add all the other features in the same way, my plan is to add more objects that can kill the enemy, and possibly a few machine gun nests that shoot a stream of bullets onto the battlefield! Not sure how Im going to do that one, but I have a few ideas , once again 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: 15th Sep 2004 07:17
Hey, glad to be of help!

I have an additional comment too, something I noticed just now when running it again. First, I changed the second collision loop I had there to detect on objects 100 to 150 (wave 2) and was dinging around it. The "set object collision off e" seems to be superfluous, so you can eliminate those lines if you want.

But second, I noted that I could click and drag the player objects around and wipe out the enemy, which might be something you don't want to allow. For that, when an object is selected as being moved you might want to turn its collision off while it is being moved, then turn it back on after the player has released it. (Since I assume you want them to block the enemy, not paint empty space over them.)

Anyway, just a suggestion... good luck with your game!
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: 15th Sep 2004 07:27
thanks! But for some reason wave 2 wont move anymore , I can see that the gosub command it there, and its pointing to the wave2 subroutine, so Im kind of confused.

By the way, yeah I noticed that the player could cheat and kill all the enemys with the swipe of the mouse, Im going on doing what you said, but in actuality I would like the objects to be un-movable after the the first wave begins, that way the player cant relocate their defense, I am kind of confused on that aspect, how do I stop the selection subroutine when the timer runs out?

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: 15th Sep 2004 08:41
Well, considering you can't see wave 2 when asked to place your defenses and you have not drawn the battlefeild distinctly so we can know how far left & right the area extends, that is a difficult call at this point. Also, I note that I barely can get one object placed before the waves begin moving, so the time limit must be increased a goodly amount.

As for the stopping, it seems that the function of;

if timeleft(0)=>0

is not working, making me think we need spaces in it as;

if timeleft(0) => 0

or;

if timeleft(0) > 0

alone. Then I suggestion moving timeleft(0) = timeleft(0) - 1 inside the if--endif with the selection call, so when timeleft(0) hits zero it stops changes the value.

But, your selection code was excessive so I'm including an optimized version under the source here, as well as that option that allows the detection to ignore an object when being moved by the player. Also, this code detects objects laying on top of one another when the waves or other objects are created, so the result looks better imho.

Good luck.. keep thinking!
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: 15th Sep 2004 09:26
Thanks alot! I dont know if you fixed wave 2 or what, but I noticed that the wave is moving up the screen as its supposed to, either you fixed it, or I just wasnt waiting long enough. Thanks again, everything is workin great!

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: 16th Sep 2004 00:03
You're welcome. I didn't do anything specifically to wave 2's movement, so perhaps it was just lack of patience on your part. Again, I suggest defining the wave play space in some manner, perhaps a backdrop of some kind for the game area. Good luck and keep thinking!
S.

Any truly great code should be indisguishable from magic.
EddieB
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location: United Kingdom
Posted: 2nd Oct 2004 17:00
Can any one help me

If its not how you do it its the way you do it.

Login to post a reply

Server time is: 2025-05-25 17:15:10
Your offset time is: 2025-05-25 17:15:10