oto kod gry lamerskiej
(w cpp siedze od 2 dni)
chce zeby sie poruszala ta gwiazdka strzalkami lewo i prawo.
lecz gdy naciskam je to stoi w miejscu
co jest nie tak???
i poprawcie moj kod bo watpie zeby byl optymalny.
aha w chars.h mam zdefinowane LEFT_ARROW etc. i to akurat jest ok
// Quake 4 =)
// Copyright 2004 by Matthew
// Date 4.03.2004
#include <iostream.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include "chars.h"
int posx,ch,posy;
void ReDraw();
void gotoxy(short x,short y);
void main ()
{
posx = 0;
posy = 22;
printf("yo");
system("PAUSE");
for(;;)
{
ch = getch();
switch(ch)
{
case LEFT_ARROW: // Lewo
posx=posx+1;
ReDraw();
case RIGHT_ARROW: // Prawo
posx=posx-1;
ReDraw();
}
}
}
void gotoxy(short x,short y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = { x,y};
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput , Cursor_an_Pos);
}
void ReDraw()
{
system("cls");
gotoxy(posx,posy);
cprintf("*");
}
POMOOOOOCY!!!!!