Language: C#
I've been at this for hours and I've gotten nowhere and I can't make anything move. Can someone show me how to make a single 2D object move using the keyboard? And perhaps explain to me how I could have figured that out from what is installed with the Dark GDK.Net so perhaps I can figure out the rest of the API on my own. I'm struggling here. Dark GDK was cool, but I was never much of a C++ programmer, I thought .Net would ease the burden but I've gotten even less done with it.
Here is the skeleton of Pong game I'm trying to create. Where would I declare the input functions, and how would I then call them to move the paddle up and down?
namespace DarkGDKApplication1
{
class dgdkApplication
{
/// <summary>
/// This is our main Game Loop. This subroutine is used for processing our
/// game events and processes during the lifetime of the application. The
/// subroutine will loop until LoopGDK returns false.
/// </summary>
///
#region Input
#endregion
public static void GameLoop()
{
//set resolution
DarkGDK.Display.SetDisplayMode(800, 600, 32);
#region Images and Sprites
//declare images
DarkGDK.Basic2D.Image ball;
//load images
ball = new DarkGDK.Basic2D.Image("ball.png");
//declare sprites
DarkGDK.Basic2D.Sprite spriteBall;
//load sprites
spriteBall = new DarkGDK.Basic2D.Sprite(ballPosX, ballPosY, ball);
#endregion
while (DarkGDK.Engine.LoopGDK)
{
DarkGDK.Core.Sync();
}
}
}
}
January 17th, 2010
So, I've figured out how to move sprites, but not via keyboard input. I added variables for X,Y, and velocity (I removed the two paddles and am just focusing on a single item, the ball).
int ballPosX = 512;
int ballPosY = 324;
float ballVelocity = 3;
I then updated the sprite method using those variables.
As far as keyboard input goes, I don't understand why the following doesn't work:
if (DarkGDK.IO.Keyboard.State(DarkGDK.IO.Keys.Up) == true)
{
//move ball based on value in ballVelocity
spriteBall.Move(ballVelocity);
}
End January 17th, 2010
"The beatings will continue until morale improves"