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.

Dark Physics & Dark A.I. & Dark Dynamix / Having problems with my first Physics game

Author
Message
fallingb
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: UK
Posted: 4th Oct 2007 18:30
Hi all,

I'm really starting to struggle now so would like it if someone could have a look at what i've done so far with regards to the below questions (Physics is new to me and i'm not sure things are going to plan)

Background.. the app is a small game (not a game as yet!) which I wrote usings DBPro and EZRotate. I'm now trying to add some physics.

Questions:
1. If you roll the ball around the level you will see strange things happening to the rotations?! (almost like the ball is floating very slightly) Should I ditch EZRotate for DPhysics commands?

2. The bullets need 'Physics`ing'... if you look at the _moveBullet: section you will see the 'remmed' out physics I have been trying. The bullets fly off in all directions. (if you rem out the MOVE line and un-rem the two phy lines you'll see what i mean)

3. If you roll off the map the ball just floats? but if you knock the barrels off, they fall.

My main problem is getting the bullets to work like they did before adding Physics.

http://www.worldtrip.co.uk/storage/Ballz.rar

Keys:
'Arrow Keys' rolls ball.
'A' and 'D' rotates crosshair.
'spacebar' shoots.

Let me know what you think of what i have done so far and how it runs on your PC's. + any points on the above questions.

Many many thanks.
Kendor
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 4th Oct 2007 19:56 Edited at: 4th Oct 2007 19:56
Q3: The problem lies in the fact that at line 109 (Ballz.dba) you are setting the Y linear velocity to 0, thus preventing it from falling. To solve this, just replace the zero with Phy get rigid body linear velocity y(player.playerObject)

Q1: Due to the problem relating to question 3, your player was not making contact with the floor and thus was not rotating. Now that there is contact it will rotate accordingly to the force direction. So you can safely remove the EzRotate commands.

I'll take a look to the bullets later

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
Programmers combine theory and practice: Nothing works and they don't know why.
fallingb
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: UK
Posted: 4th Oct 2007 20:33
Many thanks Kendor!!

I just can't seem to see these errors in logic at the moment. I've only just started Dark Basic Pro (only bought it about 3 weeks ago) and have jumped right in!!! I'm enjoy the learning very much albeit finding it hard.

Any help on the bullets too would be truly grateful.
Kendor
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 4th Oct 2007 21:48 Edited at: 4th Oct 2007 21:52
No problem. It is difficult for everyone at first

Try this:



For this to work you need to insert in the Bullet type another variable named BULLETMOVING.

There are comments for everything I added but the most important changes I made were:

- change bullet placing to be outside object so there is no collision with player
- applied force using trigonometry, so that it will move according to the player direction
- set the y linear velocity to 0 every loop, so that it will not be affected by gravity.

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
Programmers combine theory and practice: Nothing works and they don't know why.
fallingb
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: UK
Posted: 4th Oct 2007 23:01
I'll give it a look later this evening.

I can't thank you enough Kendor. Hopefully I will be able to 'crowbar' these adjustments into my code. I will let you know.

Thank you again. I will let you know how i get on...
fallingb
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: UK
Posted: 5th Oct 2007 01:26
Kendor,

Thank you for the updated 'Bullet Code'. It all works great for the first 50 bullets but when it comes to 'recycling' the spheres things seem to go astray... i'm guessing it is my lack of experience again, trying to reset things.

The first time the bullet objects are used, they are set 'phy make rigid body dynamic box' - therefore when it comes to reusing, wont this setting affect things?!

The second time around, the bullets either don't show OR show in weird locations and seem to jump around. I feel bad asking you to look at this new problem as you probably have your own stuff you're working on.... but, if you get a free moment sometime
Kendor
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 7th Oct 2007 13:37 Edited at: 7th Oct 2007 13:38
The problem is that although you are positioning the object, it still has the previous forces on him, and thus acts accordingly.

The best way to proceed is to delete the physics body using phy delete rigid body. By doing so, you will revert it to a normal object which you can position normally. Remember also to reset the variables that were changed when you fired.

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
Programmers combine theory and practice: Nothing works and they don't know why.
fallingb
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: UK
Posted: 7th Oct 2007 17:19
Cheers again... I have it all fixed and working properly now.

I can get on with the visuals now some of the 'donket-work' is done.

Thanks again!

Login to post a reply

Server time is: 2024-10-18 04:05:13
Your offset time is: 2024-10-18 04:05:13