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 / opposite angles of sprites

Author
Message
Gatorules
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location:
Posted: 21st Dec 2008 20:07
I am trying to make a very simple game and in the part of the code that I am stuck on I want the ball to bounce off of a blocker and set the angle to the opposite direction. Can someone please help me. I am pretty sure that the problem is in the part that says "-1*ballangle+360).

Here is my code:
if ( dbSpriteCollision ( ball, blocker ) )
dbRotateSprite( ball, -1*dbSpriteAngle(ball)+360);
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 22nd Dec 2008 01:20 Edited at: 22nd Dec 2008 01:20
try:

wrapvalue(ballangle+180)

...for easy 'opposite direction' behavior.

Virtual Nomad @ California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 30th Dec 2008 17:50
This looks like GDK, but anyways...

Quote: "if ( dbSpriteCollision ( ball, blocker ) )"


This looks like it needs a condition....

Quote: "dbRotateSprite( ball, -1*dbSpriteAngle(ball)+360);"


Just put



That will do less math, so more speed, and it will rotate the according sprite correctly... Not sure how you have it set up, but that is what I would think would make it work...

Login to post a reply

Server time is: 2024-11-25 14:53:39
Your offset time is: 2024-11-25 14:53:39