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|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,14 @@ class BoulderDash : Game
|
||||||
{
|
{
|
||||||
GameState.sceneManager.GetCurrentScene()?.OnMouseDown(context, e.button.button, e.button.x, e.button.y);
|
GameState.sceneManager.GetCurrentScene()?.OnMouseDown(context, e.button.button, e.button.x, e.button.y);
|
||||||
}
|
}
|
||||||
|
if (e.type == SDL_EventType.SDL_MOUSEBUTTONUP)
|
||||||
|
{
|
||||||
|
GameState.sceneManager.GetCurrentScene()?.OnMouseUp(context, e.button.button, e.button.x, e.button.y);
|
||||||
|
}
|
||||||
|
if (e.type == SDL_EventType.SDL_MOUSEMOTION)
|
||||||
|
{
|
||||||
|
GameState.sceneManager.GetCurrentScene()?.OnMouseMotion(context, e.button.x, e.button.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GameState.keyState = new KeyState();
|
GameState.keyState = new KeyState();
|
||||||
GameState.tick = (GameState.tick + 1);
|
GameState.tick = (GameState.tick + 1);
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ class Diamond : Tile
|
||||||
{
|
{
|
||||||
if (map.GetTile(x, y + 1) is (int)TileType.AIR)
|
if (map.GetTile(x, y + 1) is (int)TileType.AIR)
|
||||||
{
|
{
|
||||||
map.SetTile(x, y, 0);
|
map.SetTile(x, y, (int)TileType.DIAMOND_FALLING);
|
||||||
map.SetTile(x, y + 1, (int)TileType.DIAMOND_FALLING);
|
|
||||||
}
|
}
|
||||||
if (map.GetTile(x, y + 1) is (int)TileType.ROCK && map.GetTile(x + 1, y) is (int)TileType.AIR && map.GetTile(x + 1, y + 1) is (int)TileType.AIR)
|
if (map.GetTile(x, y + 1) is (int)TileType.ROCK && map.GetTile(x + 1, y) is (int)TileType.AIR && map.GetTile(x + 1, y + 1) is (int)TileType.AIR)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ class Player : Tile
|
||||||
private bool direction = true;
|
private bool direction = true;
|
||||||
private int idleCD = 512;
|
private int idleCD = 512;
|
||||||
private TileSet tileSet;
|
private TileSet tileSet;
|
||||||
|
private int age = 0;
|
||||||
|
|
||||||
public Player(TileSet tileSet, int srcX, int srcY) : base(tileSet, srcX, srcY)
|
public Player(TileSet tileSet, int srcX, int srcY) : base(tileSet, srcX, srcY)
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +28,23 @@ class Player : Tile
|
||||||
|
|
||||||
public override void Draw(Context context, int x, int y)
|
public override void Draw(Context context, int x, int y)
|
||||||
{
|
{
|
||||||
|
if (age < 12 * 16)
|
||||||
|
{
|
||||||
|
if (age % 32 < 16)
|
||||||
|
{
|
||||||
|
context.renderer.DrawTileSet(tileSet, x, y, 1, 6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.renderer.DrawTileSet(tileSet, x, y, 2, 6);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (age < 15 * 16)
|
||||||
|
{
|
||||||
|
context.renderer.DrawTileSet(tileSet, x, y, 1 + (age - 12 * 16) / 16, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var animation = Animation.NORMAL;
|
var animation = Animation.NORMAL;
|
||||||
var tileX = 0;
|
var tileX = 0;
|
||||||
if (isMoving)
|
if (isMoving)
|
||||||
|
|
@ -61,6 +79,8 @@ class Player : Tile
|
||||||
++j;
|
++j;
|
||||||
j = j % 32;
|
j = j % 32;
|
||||||
tileXWalk = (int)(j * (8.0 / 32.0));
|
tileXWalk = (int)(j * (8.0 / 32.0));
|
||||||
|
age++;
|
||||||
|
if (age < 15 * 16) return;
|
||||||
if (GameState.keyState.isPressed(Control.UP) && walkCD is 0)
|
if (GameState.keyState.isPressed(Control.UP) && walkCD is 0)
|
||||||
{
|
{
|
||||||
if (!map.IsSolid(x, y - 1) || map.IsSemiSolid(x, y - 1))
|
if (!map.IsSolid(x, y - 1) || map.IsSemiSolid(x, y - 1))
|
||||||
|
|
@ -86,6 +106,12 @@ class Player : Tile
|
||||||
map.SetTile(x - 1, y, 9);
|
map.SetTile(x - 1, y, 9);
|
||||||
map.SetTile(x, y, 0);
|
map.SetTile(x, y, 0);
|
||||||
}
|
}
|
||||||
|
if (map.GetTile(x - 1, y) is (int)TileType.ROCK && map.GetTile(x - 2, y) is (int)TileType.AIR)
|
||||||
|
{
|
||||||
|
map.SetTile(x - 1, y, 9);
|
||||||
|
map.SetTile(x - 2, y, (int)TileType.ROCK);
|
||||||
|
map.SetTile(x, y, 0);
|
||||||
|
}
|
||||||
walkCD = TICKS_PER_TILE;
|
walkCD = TICKS_PER_TILE;
|
||||||
}
|
}
|
||||||
if (GameState.keyState.isPressed(Control.RIGHT) && walkCD is 0)
|
if (GameState.keyState.isPressed(Control.RIGHT) && walkCD is 0)
|
||||||
|
|
@ -95,6 +121,12 @@ class Player : Tile
|
||||||
map.SetTile(x + 1, y, 9);
|
map.SetTile(x + 1, y, 9);
|
||||||
map.SetTile(x, y, 0);
|
map.SetTile(x, y, 0);
|
||||||
}
|
}
|
||||||
|
if (map.GetTile(x + 1, y) is (int)TileType.ROCK && map.GetTile(x + 2, y) is (int)TileType.AIR)
|
||||||
|
{
|
||||||
|
map.SetTile(x + 1, y, 9);
|
||||||
|
map.SetTile(x + 2, y, (int)TileType.ROCK);
|
||||||
|
map.SetTile(x, y, 0);
|
||||||
|
}
|
||||||
walkCD = TICKS_PER_TILE;
|
walkCD = TICKS_PER_TILE;
|
||||||
}
|
}
|
||||||
if (GameState.keyState.isPressed(Control.LEFT) || GameState.keyState.isPressed(Control.RIGHT))
|
if (GameState.keyState.isPressed(Control.LEFT) || GameState.keyState.isPressed(Control.RIGHT))
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ class Rock : Tile
|
||||||
{
|
{
|
||||||
if (map.GetTile(x, y + 1) is (int)TileType.AIR)
|
if (map.GetTile(x, y + 1) is (int)TileType.AIR)
|
||||||
{
|
{
|
||||||
map.SetTile(x, y, 0);
|
map.SetTile(x, y, (int)TileType.ROCK_FALLING);
|
||||||
map.SetTile(x, y + 1, (int)TileType.ROCK_FALLING);
|
|
||||||
}
|
}
|
||||||
if (map.GetTile(x, y + 1) is (int)TileType.ROCK && map.GetTile(x + 1, y) is (int)TileType.AIR && map.GetTile(x + 1, y + 1) is (int)TileType.AIR)
|
if (map.GetTile(x, y + 1) is (int)TileType.ROCK && map.GetTile(x + 1, y) is (int)TileType.AIR && map.GetTile(x + 1, y + 1) is (int)TileType.AIR)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,7 @@ static class GameState
|
||||||
public static int fps = 0;
|
public static int fps = 0;
|
||||||
public static int tick = 0;
|
public static int tick = 0;
|
||||||
public static bool saving = false;
|
public static bool saving = false;
|
||||||
|
public static double scale = 1.5;
|
||||||
|
public static double camX = 0;
|
||||||
|
public static double camY = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,19 @@ abstract class Scene : Actor
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnMouseUp(Context context, byte button, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnMouseMotion(Context context, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void OnKeyDown(Context context, SDL2.SDL.SDL_Keycode key, SDL2.SDL.SDL_Keymod mod)
|
public virtual void OnKeyDown(Context context, SDL2.SDL.SDL_Keycode key, SDL2.SDL.SDL_Keymod mod)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ static class TileSetRendererExtension
|
||||||
};
|
};
|
||||||
var dst = new SDL_Rect
|
var dst = new SDL_Rect
|
||||||
{
|
{
|
||||||
x = x,
|
x = (int)((x - GameState.camX) * GameState.scale),
|
||||||
y = y,
|
y = (int)((y - GameState.camY) * GameState.scale),
|
||||||
w = tileSet.Resolution,
|
w = (int)(tileSet.Resolution * GameState.scale),
|
||||||
h = tileSet.Resolution
|
h = (int)(tileSet.Resolution * GameState.scale)
|
||||||
};
|
};
|
||||||
SDL_RenderCopy(renderer.GetRaw(), tileSet.Texture, ref src, ref dst);
|
SDL_RenderCopy(renderer.GetRaw(), tileSet.Texture, ref src, ref dst);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class Level : Scene
|
||||||
{
|
{
|
||||||
private Map? map;
|
private Map? map;
|
||||||
private int debugSelectedTile = 1;
|
private int debugSelectedTile = 1;
|
||||||
|
private bool drawing = false;
|
||||||
private TileSet? tileSet;
|
private TileSet? tileSet;
|
||||||
private Dictionary<int, Tile>? tiles;
|
private Dictionary<int, Tile>? tiles;
|
||||||
|
|
||||||
|
|
@ -42,7 +43,7 @@ class Level : Scene
|
||||||
this.map!.Draw(context);
|
this.map!.Draw(context);
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
context.renderer.SetColor(0, 0, 0);
|
context.renderer.SetColor(0, 0, 0);
|
||||||
context.renderer.DrawRect(0, 0, 34, 34);
|
context.renderer.DrawRect(0, 0, (int)(34 * GameState.scale), (int)(34 * GameState.scale));
|
||||||
if (tiles?.ContainsKey(debugSelectedTile) == true)
|
if (tiles?.ContainsKey(debugSelectedTile) == true)
|
||||||
{
|
{
|
||||||
tiles[debugSelectedTile]!.Draw(context, 0, 0);
|
tiles[debugSelectedTile]!.Draw(context, 0, 0);
|
||||||
|
|
@ -50,7 +51,7 @@ class Level : Scene
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.renderer.SetColor(255, 0, 255);
|
context.renderer.SetColor(255, 0, 255);
|
||||||
context.renderer.DrawRect(0, 0, 32, 32);
|
context.renderer.DrawRect(0, 0, (int)(32 * GameState.scale), (int)(32 * GameState.scale));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -60,12 +61,39 @@ class Level : Scene
|
||||||
this.map!.Update(context);
|
this.map!.Update(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMouseDown(Context context, byte button, int x, int y)
|
public override void OnMouseUp(Context context, byte button, int x, int y)
|
||||||
{
|
{
|
||||||
var tileX = x / 32;
|
|
||||||
var tileY = y / 32;
|
|
||||||
if (button == SDL2.SDL.SDL_BUTTON_LEFT)
|
if (button == SDL2.SDL.SDL_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
|
this.drawing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnMouseMotion(Context context, int x, int y)
|
||||||
|
{
|
||||||
|
if (x < 0 || y < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.drawing)
|
||||||
|
{
|
||||||
|
var tileX = (int)(x / GameState.scale) / 32;
|
||||||
|
var tileY = (int)(y / GameState.scale) / 32;
|
||||||
|
this.map!.SetTile(tileX, tileY, debugSelectedTile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnMouseDown(Context context, byte button, int x, int y)
|
||||||
|
{
|
||||||
|
var tileX = (int)(x / GameState.scale) / 32;
|
||||||
|
var tileY = (int)(y / GameState.scale) / 32;
|
||||||
|
if (button == SDL2.SDL.SDL_BUTTON_LEFT)
|
||||||
|
{
|
||||||
|
this.drawing = true;
|
||||||
|
if (x < 0 || y < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.map!.SetTile(tileX, tileY, this.debugSelectedTile);
|
this.map!.SetTile(tileX, tileY, this.debugSelectedTile);
|
||||||
}
|
}
|
||||||
if (button == SDL2.SDL.SDL_BUTTON_MIDDLE)
|
if (button == SDL2.SDL.SDL_BUTTON_MIDDLE)
|
||||||
|
|
@ -85,16 +113,24 @@ class Level : Scene
|
||||||
{
|
{
|
||||||
this.debugSelectedTile = number;
|
this.debugSelectedTile = number;
|
||||||
}
|
}
|
||||||
if (key == SDL2.SDL.SDL_Keycode.SDLK_e && mod == SDL2.SDL.SDL_Keymod.KMOD_CTRL)
|
if (key == SDL2.SDL.SDL_Keycode.SDLK_e && mod == SDL2.SDL.SDL_Keymod.KMOD_LCTRL)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Saving...");
|
Console.WriteLine("Saving...");
|
||||||
var json = this.map!.ToJson();
|
var json = this.map!.ToJson();
|
||||||
context.resourceLoader.SaveString("assets.level1.json", json);
|
context.resourceLoader.SaveString("assets.level1.json", json);
|
||||||
}
|
}
|
||||||
if (key == SDL2.SDL.SDL_Keycode.SDLK_r && mod == SDL2.SDL.SDL_Keymod.KMOD_CTRL)
|
if (key == SDL2.SDL.SDL_Keycode.SDLK_r && mod == SDL2.SDL.SDL_Keymod.KMOD_LCTRL)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Reloading...");
|
Console.WriteLine("Reloading...");
|
||||||
this.Create(context);
|
this.Create(context);
|
||||||
}
|
}
|
||||||
|
if (key == SDL2.SDL.SDL_Keycode.SDLK_p)
|
||||||
|
{
|
||||||
|
GameState.scale += 0.25;
|
||||||
|
}
|
||||||
|
if (key == SDL2.SDL.SDL_Keycode.SDLK_o)
|
||||||
|
{
|
||||||
|
GameState.scale -= 0.25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue