-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswed.c
104 lines (100 loc) · 2.15 KB
/
swed.c
1
2
3
4
5
6
7
8
9
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
100
101
102
103
104
int main_edit_loop(void){
FILE *infile;
int xp,yp,lev,im;
GraphicsContext realscreen;
GraphicsContext virtualscreen;
int current_block;
initialise();
load_graphics();
infile = fopen("levelshi","rb");
for(lev=0;lev<20;lev++) {
for(xp = 0; xp < 64; xp++) {
for(yp = 0; yp <48; yp++) {
fread(&(levels[lev][xp][yp]),1,1,infile);
}
}
}
fclose(infile);
xp = yp = 0;
keyboard_init();
gl_setcontextvga(10);
gl_getcontext( &realscreen );
gl_setcontextvgavirtual(10);
gl_getcontext( &virtualscreen );
current_block = 0;
while(1) {
keyboard_update();
if(keyboard_keypressed(SCANCODE_Q)) {
yp--;
if(yp<0) {
yp=0;
}
}
if(keyboard_keypressed(SCANCODE_A)) {
yp++;
if(yp>47) {
yp=47;
}
}
if(keyboard_keypressed(SCANCODE_O)) {
xp--;
if(xp<0) {
xp = 0;
}
}
if(keyboard_keypressed(SCANCODE_P)) {
xp++;
if(xp>63) {
xp = 63;
}
}
if(keyboard_keypressed(SCANCODE_CURSORBLOCKUP)) {
current_block+=4;
if(current_block > 255) {
current_block = 0;
}
}
if(keyboard_keypressed(SCANCODE_CURSORBLOCKDOWN)) {
current_block-=4;
if(current_block < 0) {
current_block = 0;
}
}
if(keyboard_keypressed(SCANCODE_CURSORUP)) {
current_level++;
if(current_level > 19) {
current_level = 19;
}
}
if(keyboard_keypressed(SCANCODE_CURSORDOWN)) {
current_level--;
if(current_level < 0) {
current_level = 0;
}
}
if(keyboard_keypressed(SCANCODE_SPACE)) {
levels[current_level][xp][yp] = current_block;
}
if(keyboard_keypressed(SCANCODE_ESCAPE)) {
infile = fopen("levelshi","wb");
for(lev=0;lev<20;lev++) {
for(xp = 0;xp < 64; xp++) {
for(yp = 0; yp <48; yp++) {
if(levels[lev][xp][yp] == 64) {
levels[lev][xp][yp] = 4;
}
fwrite(&(levels[lev][xp][yp]),1,1,infile);
}
}
}
fclose(infile);
keyboard_close();
exit(1);
}
draw_screen(xp,yp);
gl_putboxmask(320,224,32,32,graphics[current_block]);
gl_copyscreen(&realscreen);
}
keyboard_close();
return EXIT_SUCCESS;
}