Compare commits
	
		
			No commits in common. "cb9c9d13a429e2f8f7b0c5feb858d08f39ea54f0" and "0ec6d2ded86af44121fd469094124fcc8bd319c4" have entirely different histories.
		
	
	
		
			cb9c9d13a4
			...
			0ec6d2ded8
		
	
		
							
								
								
									
										11
									
								
								level.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								level.c
									
									
									
									
									
								
							| @ -36,20 +36,17 @@ void init_level(Game *g, Level *l, char *filepath) { | ||||
| } | ||||
| 
 | ||||
| Color COLORS[4] = {BLACK, DARKGRAY, GRAY, LIGHTGRAY}; | ||||
| void draw_tile(Level *l, float x, float y) { | ||||
|   size_t index = (size_t)(x + (y * l->width)) % l->data_size; | ||||
|   size_t data = l->data[index]; | ||||
| void draw_tile(Level *l, int x, int y) { | ||||
|   size_t index = x + (y * l->width); | ||||
|   size_t data = l->data[index] & 3; | ||||
|   Color c = COLORS[data]; | ||||
|   DrawRectangle(x * 32, y * 32, 32, 32, c); | ||||
| } | ||||
| 
 | ||||
| void draw_level(Level *l) { | ||||
|   Camera2D *camera = l->game->camera; | ||||
|   float y = l->game->player->position.y; | ||||
|   y /= 32; | ||||
| 
 | ||||
|   for (int i = 0; i < l->width; i++) { | ||||
|     for (int j = y - 15; j < y + 15; j++) { | ||||
|     for (int j = 0; j < l->length; j++) { | ||||
|       draw_tile(l, i, j); | ||||
|     } | ||||
|   } | ||||
|  | ||||
							
								
								
									
										3
									
								
								player.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								player.c
									
									
									
									
									
								
							| @ -36,7 +36,6 @@ void handle_player_input(Player *p) { | ||||
| 
 | ||||
| void draw_player(Player *p) { | ||||
|   DrawTextureRec(p->spritesheet, (Rectangle) { 128, 128, 128, 128 }, (Vector2) { p->position.x - 64, p->position.y - 29 }, WHITE); | ||||
|   DrawRectangle(p->position.x, p->position.y, 5, 5, BLUE); | ||||
| } | ||||
| 
 | ||||
| void move_player(Player *p) { | ||||
| @ -69,7 +68,7 @@ void move_player(Player *p) { | ||||
|   if (too_far_left) { | ||||
|     p->game->camera->offset.x = p->position.x; | ||||
|   } else if (too_far_right) { | ||||
|     p->game->camera->offset.x = p->position.x - level_width_in_pixels + 800; | ||||
|     p->game->camera->offset.x = p->position.x - 800; | ||||
|   } else { | ||||
|     p->game->camera->offset.x = 400; | ||||
|     p->game->camera->offset.y = 275; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user