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.

Newcomers DBPro Corner / Object Intersection in DBPro

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 18th Oct 2005 04:33
The core code that I am using is Ruccus' tutorial code, but I am trying to tweak it to my liking. I want there to be an ammo crate, armor crate, sniper rifle, and shotgun. When the player passes over the armor crate, I want it to be delete and display armor HP over the original player hp in the bottom left of the screen. When the enemy fires at you and hits you, your armor hp will be decreased instead of your player hp until armor hp receahes 0, then your original hp is deducted. The problem is, when I run over the armor crate, DarkBASIC Pro tells me that 'the object does not exist at line 129'. What's up with that?



the bold part is where i'm having problems i think.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 18th Oct 2005 04:47 Edited at: 18th Oct 2005 04:54
Ill take a looksy...

P.S: Cant do bold in code boxes

<EDIT>

Found er', here's what the code should be:



Your original code was checking IF OBJECT EXIST(3)=1 and if the intersection was occuring at the same time, you need to first check if the object exists, then use a seperate if statement to check for intersection, or else the system will check if both factors are true. I know its wierd but now it should work, goodluck! Glad to see someone progressing with the tutorial, even though I'm not. I was going to add the next few chapters tomorrow but you've inspired me to do it by tonight, cheers

P.S: You've definitely got the hang of things, the method you're using is almost exact to the method I was going to introduce for obtaining ammo. Also, not sure if you want it to be like this but your movement code is a bit screwy...When facing one direction you move fast and when facing the op direction you move much slower...o.O


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 19th Oct 2005 23:26
Quote: "Glad to see someone progressing with the tutorial"


I'm glad that you made this tutorial. It has helped me to understand A LOT!!! Keep it up chief!!!

Quote: "your movement code is a bit screwy...When facing one direction you move fast and when facing the op direction you move much slower"


I wanted it to be like, when you are running foward, you run your fastest like in real-life, but when you run at an angle (while still looking at your target) you go a bit slower. I need to look back over it though.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 20th Oct 2005 03:08
Just change the speed the user moves with the a and d keys, right now its moving the user at 1 unit per sync i believe, just decrease it to something like .5 units per sync and they'll move slower when strafing or moving on an angle. Well actually they'll move faster when moving on an angle, to compensate...ack, just do something like this:

IF KEYSTATE(17)=1
IF KEYSTATTE(30)=0 AND KEYSTATE(32)=0 THEN MOVE OBJECT 1,1
IF KEYSTATE(30)=1 OR KEYSTATE(32)=1 THEN MOVE OBJECT 1,.5
ENDIF
IF KEYSTATE(31)=1 THEN MOVE OBJECT 1,-1
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.5
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.5

Basically if the user were to press both A and W, they'd actually be moving at 2 units per sync. So to compensate we check if the user is pressing A WHILE or D WHILE they're pressing W, if so we move them slower than if they were just holding W. Subsitute that code with your current movement code and it should work, I just threw it together in literally seconds as I'm infact writing more chapters for the tutorial so it may not work, just experiment you'll get it. Perhaps I'll add a section for doing things like this in the tutorial, not right now though. Goodluck.

Login to post a reply

Server time is: 2024-09-24 07:31:28
Your offset time is: 2024-09-24 07:31:28