Fixed bug with multiple sprites in editor

This commit is contained in:
Rob Pearce 2008-09-27 11:35:24 +00:00
parent 90b6c34324
commit c3c3bf6579
2 changed files with 55 additions and 34 deletions

66
edit.c
View File

@ -208,30 +208,28 @@ int main (int argc, char **argv) {
y = (my / TILEH); y = (my / TILEH);
/* checks */ /* checks */
if (toggletimer == 0) { // can only have one player start pos
// can only have one player start pos if (selsprite == P_PLAYER) {
if (selsprite == P_PLAYER) { /* does a player start pos already exist? */
/* does a player start pos already exist? */ sprite_t *s;
sprite_t *s; for (s = sprite ; s ; s = s->next) {
for (s = sprite ; s ; s = s->next) { if (s->id == P_PLAYER) {
if (s->id == P_PLAYER) { // if so, just move it
// if so, just move it s->x = x*TILEW+(TILEW/2);
s->x = x*TILEW+(TILEW/2); s->y = y*TILEH+TILEH;
s->y = y*TILEH+TILEH; placed = B_TRUE;
placed = B_TRUE; modified = B_TRUE;
modified = B_TRUE; // get rid of old sprite
// get rid of old sprite draweditorlevel();
draweditorlevel();
}
} }
} else { // is there a monster already there? }
sprite_t *s; } else { // is there a monster already there?
for (s = sprite ; s ; s = s->next) { sprite_t *s;
if (s->id == selsprite) { for (s = sprite ; s ; s = s->next) {
if ((s->x == x*TILEW+(TILEW/2)) && (s->y == y*TILEH+TILEH)) { if (s->id == selsprite) {
/* don't place it */ if ((s->x == x*TILEW+(TILEW/2)) && (s->y == y*TILEH+TILEH)) {
placed = B_TRUE; /* don't place it */
} placed = B_TRUE;
} }
} }
} }
@ -239,16 +237,19 @@ int main (int argc, char **argv) {
if (!placed) { if (!placed) {
/* place selected sprite at mouse position if (toggletimer == 0) {
(locked to a til) */ /* place selected sprite at mouse position
if (selsprite == P_HELP) { (locked to a tile) */
addsprite(selsprite, x*TILEW+(TILEW/2),y*TILEH+TILEH,"FILL ME IN", B_TRUE); if (selsprite == P_HELP) {
} else { addsprite(selsprite, x*TILEW+(TILEW/2),y*TILEH+TILEH,"FILL ME IN", B_TRUE);
addsprite(selsprite, x*TILEW+(TILEW/2),y*TILEH+TILEH,"something", B_TRUE); } else {
addsprite(selsprite, x*TILEW+(TILEW/2),y*TILEH+TILEH,"something", B_TRUE);
}
printf("added a sprite\n");
toggletimer = 30;
modified = B_TRUE;
drawsprites();
} }
toggletimer = 30;
modified = B_TRUE;
drawsprites();
} }
} }
@ -307,6 +308,7 @@ int main (int argc, char **argv) {
drawtile(screen,x,y); drawtile(screen,x,y);
} }
} }
printf("cleared level\n");
} }
} }

View File

@ -9,10 +9,29 @@ monsters
C 33 7 C 33 7
C 11 13 C 11 13
r 13 5 r 13 5
r 19 21
r 7 17 r 7 17
S 28 24
s 23 1 s 23 1
@ 7 5
@ 25 9
P 25 5
P 7 9
Y 2 7
Y 1 7
Y 2 12
Y 1 12
Y 38 7
Y 30 7
Y 35 15
Y 38 15
Y 32 18
Y 9 21
Y 7 21
@ 18 17
@ 4 17
P 36 24
P 38 24
S 31 24
r 20 21
endmonsters endmonsters
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,