Hi,
I'm doing some tests with sprites on one my tests I decided to allow the user change the conditions by drawing in the screen. This is what I have so far, it looks good but if you move the mouse too quickly some sprites became isolated.
P.S hold left mouse button to draw and space bar to drop the ball on the mouse position
#include "Main.h"
using namespace AGK;
app App;
int spriteID = 7;
int colision = 0;
char str[50];
float fObjX = 50.0f;
float fObjY = 0.0f;
void app::Begin (void){
agk::SetVirtualResolution ( 320, 480 );
agk::EnableClearColor ( 0 );
int backdrop = agk::CreateSprite ( agk::LoadImage ( "../Data/background1.jpg" ) );
agk::LoadImage ( 2, "../Data/ball.png" );
agk::LoadImage ( 3, "../Data/crate.jpg" );
agk::LoadImage ( 4, "../Data/point.png" );
agk::CreateSprite(3,2);
agk::SetSpritePosition(3,fObjX, fObjY);
agk::SetSpriteSize(3,35.0f,35.0f);
agk::SetSpriteShape(3, 1);
agk::SetSpritePhysicsMass(3, 1.5f);
agk::SetSpritePhysicsOn (3,1);
//agk::SetPhysicsDebugOn();
}
void app::Loop(void){
sprintf ( str, "Colision: %i Colision Aux: %i ", agk::GetPhysicsCollision(3,6),colision );
agk::Print(str);
if (agk::GetRawKeyPressed(32))
{
fObjX = agk::GetPointerX ();
fObjY = agk::GetPointerY ();
agk::SetSpritePosition(3,fObjX,fObjY);
agk::SetSpritePhysicsDelete(3);
agk::SetSpritePhysicsOn (3, 2);
}
if (agk::GetPointerState())
{
if(agk::GetSpriteExists(spriteID) == 0)
agk::CreateSprite(spriteID,4);
agk::SetSpritePosition(spriteID,agk::GetPointerX (), agk::GetPointerY ());
agk::SetSpriteSize(spriteID,10.0f,10.0f);
agk::SetSpriteShape(spriteID, 1);
agk::SetSpritePhysicsOn (spriteID,3);
spriteID++;
}
agk::SetSpritePhysicsRestitution( 3, 0.5f);
agk::SetSpritePhysicsRestitution( 6, 2.5f);
agk::Sync();
}
void app::End(void){
}