- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
#include <stdio.h>
#include <stdlib.h>
#include <gb/gb.h>
#include <gb/drawing.h>
#include <rand.h>
#define OBJ_EMPTY 0
#define OBJ_PLAYER 1
#define OBJ_ENEMY 2
void clearscr(void);
void waitbuttona(void);
void initgame(void);
void setcubemem(UINT8 formerx,UINT8 formery);
void enemy(void);
void wingame(void);
int game_field[5][5];
int cube_x = 2;
int cube_y = 3;
int fcx = 0;
int fcy = 0;
UINT8 genenemy = 0;
UINT8 button;
int pointx = 0;
int pointy = 0;
int i = 0;
int u = 0;
int main()
{
initrand(31415);
printf("Running Cube");
waitbuttona();
clearscr();
initgame();
while(1)
{
clearscr();
button = joypad();
fcx = cube_x;
fcy = cube_y;
genenemy = rand();
if(button == J_UP){ cube_x--; setcubemem(fcx,fcy); }
if(button == J_DOWN){ cube_x++; setcubemem(fcx,fcy);}
if(button == J_LEFT){ cube_y--; setcubemem(fcx,fcy);}
if(button == J_RIGHT){ cube_y++; setcubemem(fcx,fcy);}
box(cube_y*20,cube_x*20,cube_y*20+10,cube_x*20+10,M_FILL);
if(genenemy % 4 == 0) enemy();
}
return(0);
}
void clearscr(void)
{
color(WHITE,WHITE,SOLID);
box(0,0,GRAPHICS_WIDTH,GRAPHICS_HEIGHT);
color(BLACK,WHITE,SOLID);
}
void waitbuttona(void)
{
while(1)
{
if(joypad() == J_A) break;
}
}
void setcubemem(UINT8 formerx,UINT8 formery)
{
game_field[formerx][formery] = 0;
game_field[cube_x][cube_y] = OBJ_PLAYER;
}
void initgame(void)
{
game_field[2][3] = OBJ_PLAYER;
}
void enemy(void)
{
initrand(2);
game_field[rand()][rand()] = OBJ_ENEMY;
circle(3*20,1*20,20,1);
if(game_field[cube_x-2][cube_y-2] == OBJ_ENEMY || game_field[cube_x-1][cube_y-1] == OBJ_ENEMY || game_field[cube_x][cube_y] == OBJ_ENEMY || game_field[cube_x+1][cube_y+1] == OBJ_ENEMY || game_field[cube_x+2][cube_y+2] == OBJ_ENEMY)
{
wingame();
}
}
void wingame(void)
{
clearscr();
gotogxy(40,50);
gprintf("You've won!");
delay(1000);
reset();
}
Игра на Gameboy Classic(GBDK,написана мною). Без комментариев.
Stertor 28.06.2015 13:20 # +2
inkanus-gray 28.06.2015 13:34 # +1
fedor2612 30.06.2015 11:44 # +1
myaut 28.06.2015 16:16 # +2
fedor2612 30.06.2015 21:40 # +1