#include <yzkgame.h>
#pragma comment( linker, "/subsystem:\"console\" /entry:\"mainCRTStartup\"" )
#pragma comment(lib, "YZKGame.lib")
void gameMain(void)
{
int mario = 0;
int ch;
int x;
int y;
setGameTitle("风中叶子");
setGameSize(600, 600);
setBgColor(2, 0, 0);
createSprite(mario, "mario");
playSpriteAnimate(mario, "happyrun");
while (TRUE) {
ch = getPressedKeyCode();
x = getSpriteX(mario);
y = getSpriteY(mario);
if (ch == RP_KEY_LEFT) {
x = x--;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, FALSE);
pauseGame(10);
}
else if (ch == RP_KEY_RIGHT)
{
x = x++;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, TRUE);
pauseGame(10);
}
else if (ch == RP_KEY_UP)
{
y = y++;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, FALSE);
pauseGame(10);
}
else if (ch == RP_KEY_DOWN)
{
y = y--;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, TRUE);
pauseGame(10);
}
}
pauseGame(10000);
}
int main(void)
{
rpInit(gameMain);
return 0;
}
#pragma comment( linker, "/subsystem:\"console\" /entry:\"mainCRTStartup\"" )
#pragma comment(lib, "YZKGame.lib")
void gameMain(void)
{
int mario = 0;
int ch;
int x;
int y;
setGameTitle("风中叶子");
setGameSize(600, 600);
setBgColor(2, 0, 0);
createSprite(mario, "mario");
playSpriteAnimate(mario, "happyrun");
while (TRUE) {
ch = getPressedKeyCode();
x = getSpriteX(mario);
y = getSpriteY(mario);
if (ch == RP_KEY_LEFT) {
x = x--;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, FALSE);
pauseGame(10);
}
else if (ch == RP_KEY_RIGHT)
{
x = x++;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, TRUE);
pauseGame(10);
}
else if (ch == RP_KEY_UP)
{
y = y++;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, FALSE);
pauseGame(10);
}
else if (ch == RP_KEY_DOWN)
{
y = y--;
setSpritePosition(mario, x, y);
setSpriteFlipX(mario, TRUE);
pauseGame(10);
}
}
pauseGame(10000);
}
int main(void)
{
rpInit(gameMain);
return 0;
}