Fixed level saving and loading
This commit is contained in:
16
code/first.c
16
code/first.c
@@ -260,8 +260,8 @@ int main(int argc, char **argv)
|
||||
if(e.type==SDL_EVENT_MOUSE_BUTTON_DOWN && e.button.button == SDL_BUTTON_LEFT) {
|
||||
switch(game->editor.mode){
|
||||
case G_EDITOR_MODE_TILE: {
|
||||
F32 tilex = (S32)(game->editor.cursor.x+TILE_SIZE/2);
|
||||
F32 tiley = (S32)(game->editor.cursor.y+TILE_SIZE/2);
|
||||
F32 tilex = (F32) (S32)(game->editor.cursor.x+TILE_SIZE/2);
|
||||
F32 tiley = (F32) (S32)(game->editor.cursor.y+TILE_SIZE/2);
|
||||
game->world->map[(S32)tilex + (S32)tiley * 96] = game->editor.currentAsset;
|
||||
break;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
|
||||
// Add hitbox
|
||||
// Add hitbox
|
||||
V2f topLeft = V2F(Min(game->editor.cursor.x, game->editor.dragStart.x), Min(game->editor.cursor.y, game->editor.dragStart.y));
|
||||
game->world->hitboxes[game->world->hitboxCount].pos = topLeft;
|
||||
game->world->hitboxes[game->world->hitboxCount].size = V2F(
|
||||
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
|
||||
UpdateWorld(1.0f / 60.0f, game->world);
|
||||
game->camera.p.x = game->world->player.pos.x;
|
||||
game->camera.p.y = game->world->player.pos.y;
|
||||
}
|
||||
}
|
||||
D_AnimationUpdate(&animation, 1.0f / 250.0f);
|
||||
|
||||
int w, h;
|
||||
@@ -395,8 +395,8 @@ int main(int argc, char **argv)
|
||||
|
||||
if(game->editor.enabled) {
|
||||
G_Editor editor = game->editor;
|
||||
F32 tilex = floor(editor.cursor.x+TILE_SIZE/2);
|
||||
F32 tiley = floor(editor.cursor.y+TILE_SIZE/2);
|
||||
F32 tilex = (F32) floor(editor.cursor.x+TILE_SIZE/2);
|
||||
F32 tiley = (F32) floor(editor.cursor.y+TILE_SIZE/2);
|
||||
switch(game->editor.mode) {
|
||||
case G_EDITOR_MODE_TILE: {
|
||||
World_Tile asset = game->world->tileTypes[editor.currentAsset];
|
||||
@@ -409,7 +409,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
case G_EDITOR_MODE_HITBOX: {
|
||||
for(int i = 0; i < game->world->hitboxCount; i++) {
|
||||
for(U32 i = 0; i < game->world->hitboxCount; i++) {
|
||||
V2f centre = AABB_Centre(game->world->hitboxes[i]);
|
||||
D_Rect(
|
||||
&game->draw,
|
||||
@@ -418,7 +418,7 @@ int main(int argc, char **argv)
|
||||
.texture=0,
|
||||
.dim=game->world->hitboxes[i].size,
|
||||
.flags=D_RECT_IGNORE_ASPECT,
|
||||
.c=V4F(100,0,0,0.7),
|
||||
.c=V4F(100,0,0,0.7f),
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user