diff --git a/Spaceinator.project.gmx b/Spaceinator.project.gmx index 6b0b710..88bdcfe 100644 --- a/Spaceinator.project.gmx +++ b/Spaceinator.project.gmx @@ -16,24 +16,28 @@ sprites\spr_enemy sprites\spr_asteroid sprites\spr_boom + sprites\spr_chunk background\bg_space - - - + objects\obj_player objects\obj_controller_world_gen objects\obj_controller objects\obj_bullet objects\obj_asteriod + objects\obj_chunk rooms\rm_game + + 32 + 16 + help.rtf diff --git a/objects/obj_controller.object.gmx b/objects/obj_controller.object.gmx index 092a883..afc299e 100644 --- a/objects/obj_controller.object.gmx +++ b/objects/obj_controller.object.gmx @@ -74,17 +74,43 @@ step_counter++; 1 /// Draw Debug Screen -var chunkRelX = obj_player.x % (CHUNK_SIZE*TILE_SIZE); -var chunkRelY = obj_player.y % (CHUNK_SIZE*TILE_SIZE) +var chunk_total_size = (CHUNK_SIZE*TILE_SIZE); -var chunkX = (obj_player.x - chunkRelX) / (CHUNK_SIZE*TILE_SIZE); -var chunkY = (obj_player.y - chunkRelY) / (CHUNK_SIZE*TILE_SIZE); +var playX = obj_player.x; +var playY = obj_player.y; + +var chunkRelX = obj_player.x % chunk_total_size; +var chunkRelY = obj_player.y % chunk_total_size; + +var chunkX = (obj_player.x - chunkRelX) / chunk_total_size; +var chunkY = (obj_player.y - chunkRelY) / chunk_total_size; +if(chunkX < 0) +{ + chunkX -= 1; +} + +if(chunkY < 0) +{ + chunkY -= 1; +} + +if(chunkY == 0 && (playY < 0 && playY >= chunk_total_size/-1)) +{ + chunkY = -1; +} + +if(chunkX == 0 && (playX < 0 && playX >= chunk_total_size/-1)) +{ + chunkX = -1; +} + draw_text(10,10,"X: "+string(obj_player.x)+"#Y: "+string(obj_player.y)); draw_text(10,40,"CrX: "+string(chunkRelX)+"#CrY: "+string(chunkRelY)); draw_text(10,70,"CX: "+string(chunkX)+"#CY: "+string(chunkY)); + diff --git a/objects/obj_controller_world_gen.object.gmx b/objects/obj_controller_world_gen.object.gmx index 4e44503..91219d4 100644 --- a/objects/obj_controller_world_gen.object.gmx +++ b/objects/obj_controller_world_gen.object.gmx @@ -50,15 +50,42 @@ 1 - var chunkRelX = obj_player.x % (CHUNK_SIZE*TILE_SIZE); -var chunkRelY = obj_player.y % (CHUNK_SIZE*TILE_SIZE) + var playX = obj_player.x; +var playY = obj_player.y; -var chunkX = (obj_player.x - chunkRelX) / (CHUNK_SIZE*TILE_SIZE); -var chunkY = (obj_player.y - chunkRelY) / (CHUNK_SIZE*TILE_SIZE) - 1; +var chunk_total_size = (CHUNK_SIZE*TILE_SIZE); -if(!place_meeting(chunkX*(CHUNK_SIZE*TILE_SIZE), chunkY*(CHUNK_SIZE*TILE_SIZE),obj_chunk)) +var chunkRelX = playX % chunk_total_size; +var chunkRelY = playY % chunk_total_size; + + +var chunkX = (obj_player.x - chunkRelX); +var chunkY = (obj_player.y - chunkRelY); + +if(chunkX < 0) { - instance_create(chunkX*(CHUNK_SIZE*TILE_SIZE),chunkY*(CHUNK_SIZE*TILE_SIZE),obj_chunk); + chunkX -= chunk_total_size; +} + +if(chunkY < 0) +{ + chunkY -= chunk_total_size; +} + +if(chunkY == 0 && (playY < 0 && playY >= chunk_total_size/-1) ) +{ + chunkY = chunk_total_size/-1; +} + +if(chunkX == 0 && (playX < 0 && playX >= chunk_total_size/-1) ) +{ + chunkX = chunk_total_size/-1; +} + + +if(!place_meeting(chunkX, chunkY,obj_chunk)) +{ + instance_create(chunkX,chunkY,obj_chunk); } diff --git a/sprites/images/spr_chunk_0.png b/sprites/images/spr_chunk_0.png index 8571f28..82f0e79 100644 Binary files a/sprites/images/spr_chunk_0.png and b/sprites/images/spr_chunk_0.png differ diff --git a/sprites/spr_chunk.sprite.gmx b/sprites/spr_chunk.sprite.gmx index c44b160..15ce81d 100644 --- a/sprites/spr_chunk.sprite.gmx +++ b/sprites/spr_chunk.sprite.gmx @@ -6,11 +6,11 @@ 1 0 0 - 0 - 511 - 0 - 511 - 0 + 1 + 0 + 511 + 0 + 511 0 0