|
|
|
@ -12,11 +12,10 @@ int main(void)
@@ -12,11 +12,10 @@ int main(void)
|
|
|
|
|
|
|
|
|
|
const int screenWidth = 800; |
|
|
|
|
const int screenHeight = 450; |
|
|
|
|
|
|
|
|
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input"); |
|
|
|
|
|
|
|
|
|
raylib::Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; |
|
|
|
|
raylib::Vector2 vel = { 0.0f, 0.0f }; |
|
|
|
|
raylib::Vector3 ballPosition = { 0,0,200 }; |
|
|
|
|
raylib::Vector3 vel = { 0.0f, 0.0f, 0.0f }; |
|
|
|
|
raylib::Vector2 accel = { 1.0f, 1.0f }; |
|
|
|
|
accel *= 1.5f; |
|
|
|
|
float decel = 0.85f; |
|
|
|
@ -25,13 +24,10 @@ int main(void)
@@ -25,13 +24,10 @@ int main(void)
|
|
|
|
|
|
|
|
|
|
while (!WindowShouldClose()) |
|
|
|
|
{ |
|
|
|
|
// Update
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
if (IsKeyDown(KEY_RIGHT)) vel.x += accel.x; |
|
|
|
|
if (IsKeyDown(KEY_LEFT)) vel.x -= accel.x; |
|
|
|
|
if (IsKeyDown(KEY_UP)) vel.y -= accel.y; |
|
|
|
|
if (IsKeyDown(KEY_DOWN)) vel.y += accel.y; |
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
vel *= decel; |
|
|
|
|
|
|
|
|
@ -40,14 +36,11 @@ int main(void)
@@ -40,14 +36,11 @@ int main(void)
|
|
|
|
|
gs.players[0].pos.x = ballPosition.x; |
|
|
|
|
gs.players[0].pos.y = ballPosition.y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
step(gs); |
|
|
|
|
draw(gs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// De-Initialization
|
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
CloseWindow(); // Close window and OpenGL context
|
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
CloseWindow(); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|