CommitLog |

This commit is contained in:
SilicaAndPina 2020-07-24 08:57:47 +12:00
parent e74edd8841
commit a9c35b6d6c
9 changed files with 128 additions and 60 deletions

View File

@ -16,14 +16,13 @@
<sprite>sprites\spr_enemy</sprite>
<sprite>sprites\spr_asteroid</sprite>
<sprite>sprites\spr_boom</sprite>
<sprite>sprites\spr_empty</sprite>
</sprites>
<backgrounds name="background">
<background>background\bg_space</background>
</backgrounds>
<paths name="paths"/>
<scripts name="scripts">
<script>scripts\generate_world.gml</script>
<script>scripts\load_chunk.gml</script>
</scripts>
<objects name="objects">
<object>objects\obj_player</object>
@ -31,7 +30,6 @@
<object>objects\obj_controller</object>
<object>objects\obj_bullet</object>
<object>objects\obj_asteriod</object>
<object>objects\obj_air</object>
</objects>
<rooms name="rooms">
<room>rooms\rm_game</room>

View File

@ -1,23 +0,0 @@
<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<object>
<spriteName>spr_empty</spriteName>
<solid>0</solid>
<visible>-1</visible>
<depth>0</depth>
<persistent>0</persistent>
<parentName>&lt;undefined&gt;</parentName>
<maskName>&lt;undefined&gt;</maskName>
<events/>
<PhysicsObject>0</PhysicsObject>
<PhysicsObjectSensor>0</PhysicsObjectSensor>
<PhysicsObjectShape>0</PhysicsObjectShape>
<PhysicsObjectDensity>0.5</PhysicsObjectDensity>
<PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution>
<PhysicsObjectGroup>0</PhysicsObjectGroup>
<PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping>
<PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping>
<PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction>
<PhysicsObjectAwake>-1</PhysicsObjectAwake>
<PhysicsObjectKinematic>0</PhysicsObjectKinematic>
<PhysicsShapePoints/>
</object>

View File

@ -48,7 +48,43 @@
<arguments>
<argument>
<kind>1</kind>
<string>step_counter++;
<string>/// Every Frame Global Code.
step_counter++;
</string>
</argument>
</arguments>
</action>
</event>
<event eventtype="8" enumb="64">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>/// Draw Debug Screen
var chunkRelX = obj_player.x % 256
var chunkRelY = obj_player.y % 256
var chunkX = (obj_player.x - chunkRelX) / 256,;
var chunkY = (obj_player.y - chunkRelY) / 256;
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));
</string>
</argument>
</arguments>
@ -71,7 +107,8 @@
<arguments>
<argument>
<kind>1</kind>
<string>if(window_get_fullscreen())
<string>/// Set fullscreen
if(window_get_fullscreen())
{
window_set_fullscreen(0);
}

View File

@ -25,7 +25,10 @@
<arguments>
<argument>
<kind>1</kind>
<string></string>
<string>loaded_chunks[64] = 0;
//load_chunk(0,0);
</string>
</argument>
</arguments>
</action>
@ -47,7 +50,15 @@
<arguments>
<argument>
<kind>1</kind>
<string>generate_world();
<string>var chunkRelX = obj_player.x % 256
var chunkRelY = obj_player.y % 256
var chunkX = (obj_player.x - chunkRelX) / 256,;
var chunkY = (obj_player.y - chunkRelY) / 256;
if(loaded_chunks[0] == 0)
loaded_chunks[0] = load_chunk(chunkX,chunkY);
</string>
</argument>
</arguments>

View File

@ -25,8 +25,10 @@
<arguments>
<argument>
<kind>1</kind>
<string>image_speed = 0;
<string>/// Player creation code.
image_speed = 0;
image_index = 1;
</string>
</argument>
</arguments>
@ -49,7 +51,8 @@ image_index = 1;
<arguments>
<argument>
<kind>1</kind>
<string>direction = image_angle
<string>/// Player per frame
direction = image_angle
if(speed &gt; 0)
speed -= 1
@ -58,6 +61,7 @@ if(speed &gt; 20)
view_xview[0] = x - view_wview[0]/2;
view_yview[0] = y - view_hview[0]/2;
</string>
</argument>
</arguments>

View File

@ -0,0 +1,20 @@
///generate_chunk()
var chunk_grid = ds_grid_create(128,128);
for(var xx = 0; xx < 128; xx++)
{
for(var yy = 0; yy < 128; yy++)
{
if(random_range(0,10) > 5)
{
chunk_grid = obj_asteriod;
}
else
{
chunk_grid = 0;
}
}
}

View File

@ -17,9 +17,7 @@ for(var xx = startx; xx < xmax; xx+=32)
{
for(var yy = starty; yy < ymax;yy+=32)
{
if(!place_free(xx,yy))
if(place_empty(xx,yy))
{
instance_create(xx,yy,obj_air);

48
scripts/load_chunk.gml Normal file
View File

@ -0,0 +1,48 @@
///load_chunk(cx,cy);
var cx = argument0
var cy = argument1
var chunk_grid = ds_grid_create(256,256);
var filename = string(cx)+","+string(cy)+".spr";
if(file_exists(filename)) // Load Chunk
{
ini_open(filename);
for(var xx = 0; xx < 256; xx++)
{
for(var yy = 0; yy < 256; yy++)
{
var nm = string(xx)+string(yy);
var c = ini_read_real("XYV",nm,0);
chunk_grid[xx,yy] = c;
if(c != 0)
instance_create(xx,yy,c);
}
}
ini_close();
}
else // Generate Chunk
{
ini_open(filename);
for(var xx = 0; xx < 256; xx++)
{
for(var yy = 0; yy < 256; yy++)
{
var nm = string(xx)+string(yy);
if(random_range(0,10) > 5)
{
ini_write_real("XYV",nm,obj_asteriod);
chunk_grid[xx,yy] = obj_asteriod;
instance_create(cx+xx,cy+yy,obj_asteriod);
}
else
{
ini_write_real("XYV",nm,0);;
chunk_grid[xx,yy] = 0;
}
}
}
ini_close();
}
return chunk_grid;

View File

@ -1,25 +0,0 @@
<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<sprite>
<type>0</type>
<xorig>0</xorig>
<yorigin>0</yorigin>
<colkind>0</colkind>
<coltolerance>0</coltolerance>
<sepmasks>-1</sepmasks>
<bboxmode>1</bboxmode>
<bbox_left>0</bbox_left>
<bbox_right>31</bbox_right>
<bbox_top>0</bbox_top>
<bbox_bottom>31</bbox_bottom>
<HTile>0</HTile>
<VTile>0</VTile>
<TextureGroups>
<TextureGroup0>0</TextureGroup0>
</TextureGroups>
<For3D>0</For3D>
<width>32</width>
<height>32</height>
<frames>
<frame index="0">images\spr_empty_0.png</frame>
</frames>
</sprite>