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 GDK / a player box stop when it hit a fixed box !!!@??

Author
Message
kareem3d
15
Years of Service
User Offline
Joined: 3rd Aug 2009
Location:
Posted: 14th Aug 2009 16:18 Edited at: 14th Aug 2009 16:22
i'm facing a small problem making my sample game ...

i made box(1) which could move with arrows but i need it not to penetrate box(2) when it moves towards it ....((box2 is fixed))

HERE'S my CODE ::

#include "DarkGDK.h"
#include "SC_Collision.h"

void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );

SC_Start();

dbMakeCamera(1);
dbPositionCamera(1,0,0,-50);

dbMakeObjectBox(1,1,1,1);
SC_SetupObject(1,8,0);

dbMakeObjectBox(2,6,3,1);
dbPositionObject(2,-10,0,0.5);
SC_SetupObject(2,8,0);

int speed=1;
float x=0;
float y=0;
float z=0;


while ( LoopGDK ( ) )
{
if(dbUpKey())
{
y=y+speed;
SC_UpdateObject(1);
}
if(dbDownKey())
{
y=y-speed;
SC_UpdateObject(1);
}
if(dbLeftKey())
{
x=x-speed;
SC_UpdateObject(1);
}
if(dbRightKey())
{
x=x+speed;
SC_UpdateObject(1);
}

int isCollision=SC_ObjectCollision(1,2);

if(isCollision==1)
{

//WHAT DO I HAVE TO WRITE HERE TO NOT MAKE BOX(1) PENETRATE BOX(2)
//BOX(1) MOVES WITH ARROWS
}

dbPositionObject(1,x,y,z);
dbSync ( );
}

return;
}
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 14th Aug 2009 17:46
that's almost the same like in your other thread!
have a look at my new post and check Sparky Documentation and Samples...
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 14th Aug 2009 19:05
Hmm, you probably shouldnt double post for the same problem cause it clutters the forums and you might get a mod giving you a noob slap if you do it to often.

Anyway, as _Pauli_ said, the best place to look at collision is in the examples that come with Sparky's if thats what you are going to use.

Although I suggest actually learning how the code works, as having other people type it out for you isnt going to teach you anything, the way I tend to figure out new code that isnt mine is by trial and error, What I mean is, change a couple of variables and have a look at the effect it has, increase them, decrease them, remove them altogether, then move on and do the same for other parts of the code. That way you will be able to see what is happening where and what parts of the code affect what...

Usually, you will end up breaking it quite a few times as you change things, but thats ok, as long as you can figure out why the change caused it to break, its still teaching you something..

Once piece of advice though is to work small, only change variable's values one at a time to start with, perhaps make them constant or keep their value at zero or something so you can see where they are being changed in the code(you cant change a contant so it will give you an error at that point in the code, and you should notice soemthing different between running it with normal values and whatever you changed to 0)

Anway, hope thats something to think about, good luck

If it ain't broke.... DONT FIX IT !!!
kareem3d
15
Years of Service
User Offline
Joined: 3rd Aug 2009
Location:
Posted: 15th Aug 2009 11:42
i know i posted that thread twice but i have been searching for an answer for that for along time.....

Anyway i managed to make it,,, thx to u

Login to post a reply

Server time is: 2024-11-20 17:24:52
Your offset time is: 2024-11-20 17:24:52