Compare commits
3 Commits
9633bcca35
...
4299a009b7
Author | SHA1 | Date | |
---|---|---|---|
4299a009b7 | |||
d270efe643 | |||
602a8297e6 |
62
.gitattributes
vendored
Normal file
62
.gitattributes
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
###############################################################################
|
||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
###############################################################################
|
||||||
|
* text=auto
|
||||||
|
*.cs text eol=lf
|
||||||
|
*.py text eol=lf
|
||||||
|
*.sh text eol=lf
|
||||||
|
###############################################################################
|
||||||
|
# Set default behavior for command prompt diff.
|
||||||
|
#
|
||||||
|
# This is need for earlier builds of msysgit that does not have it on by
|
||||||
|
# default for csharp files.
|
||||||
|
# Note: This is only used by command line
|
||||||
|
###############################################################################
|
||||||
|
#*.cs diff=csharp
|
||||||
|
###############################################################################
|
||||||
|
# Set the merge driver for project and solution files
|
||||||
|
#
|
||||||
|
# Merging from the command prompt will add diff markers to the files if there
|
||||||
|
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||||
|
# the diff markers are never inserted). Diff markers may cause the following
|
||||||
|
# file extensions to fail to load in VS. An alternative would be to treat
|
||||||
|
# these files as binary and thus will always conflict and require user
|
||||||
|
# intervention with every merge. To do so, just uncomment the entries below
|
||||||
|
###############################################################################
|
||||||
|
#*.sln merge=binary
|
||||||
|
#*.csproj merge=binary
|
||||||
|
#*.vbproj merge=binary
|
||||||
|
#*.vcxproj merge=binary
|
||||||
|
#*.vcproj merge=binary
|
||||||
|
#*.dbproj merge=binary
|
||||||
|
#*.fsproj merge=binary
|
||||||
|
#*.lsproj merge=binary
|
||||||
|
#*.wixproj merge=binary
|
||||||
|
#*.modelproj merge=binary
|
||||||
|
#*.sqlproj merge=binary
|
||||||
|
#*.wwaproj merge=binary
|
||||||
|
###############################################################################
|
||||||
|
# behavior for image files
|
||||||
|
#
|
||||||
|
# image files are treated as binary by default.
|
||||||
|
###############################################################################
|
||||||
|
*.jpg binary
|
||||||
|
*.png binary
|
||||||
|
*.gif binary
|
||||||
|
###############################################################################
|
||||||
|
# diff behavior for common document formats
|
||||||
|
#
|
||||||
|
# Convert binary document formats to text before diffing them. This feature
|
||||||
|
# is only available from the command line. Turn it on by uncommenting the
|
||||||
|
# entries below.
|
||||||
|
###############################################################################
|
||||||
|
#*.doc diff=astextplain
|
||||||
|
#*.DOC diff=astextplain
|
||||||
|
#*.docx diff=astextplain
|
||||||
|
#*.DOCX diff=astextplain
|
||||||
|
#*.dot diff=astextplain
|
||||||
|
#*.DOT diff=astextplain
|
||||||
|
#*.pdf diff=astextplain
|
||||||
|
#*.PDF diff=astextplain
|
||||||
|
#*.rtf diff=astextplain
|
||||||
|
#*.RTF diff=astextplain
|
@ -1,7 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace SemiColinGames {
|
namespace SemiColinGames {
|
||||||
class NPC {
|
class NPC {
|
||||||
|
@ -56,8 +56,7 @@ namespace SemiColinGames {
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(
|
public void Draw(bool isRunningSlowly, World world, LinesOfSight linesOfSight, bool paused) {
|
||||||
bool isRunningSlowly, World world, Player player, LinesOfSight linesOfSight, bool paused) {
|
|
||||||
graphics.SetRenderTarget(null);
|
graphics.SetRenderTarget(null);
|
||||||
graphics.Clear(backgroundColor);
|
graphics.Clear(backgroundColor);
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ namespace SemiColinGames {
|
|||||||
world.DrawBackground(spriteBatch);
|
world.DrawBackground(spriteBatch);
|
||||||
|
|
||||||
// Draw player.
|
// Draw player.
|
||||||
player.Draw(spriteBatch);
|
world.Player.Draw(spriteBatch);
|
||||||
|
|
||||||
// Draw foreground tiles.
|
// Draw foreground tiles.
|
||||||
world.DrawForeground(spriteBatch);
|
world.DrawForeground(spriteBatch);
|
||||||
@ -112,9 +111,9 @@ namespace SemiColinGames {
|
|||||||
// Draw in-world UI on top of everything.
|
// Draw in-world UI on top of everything.
|
||||||
spriteBatch.Begin(
|
spriteBatch.Begin(
|
||||||
SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);
|
SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);
|
||||||
for (int i = 0; i < player.MaxHealth; i++) {
|
for (int i = 0; i < world.Player.MaxHealth; i++) {
|
||||||
Vector2 pos = new Vector2(16 + 15 * i, 8);
|
Vector2 pos = new Vector2(16 + 15 * i, 8);
|
||||||
if (player.Health > i) {
|
if (world.Player.Health > i) {
|
||||||
spriteBatch.Draw(Textures.Heart.Get, pos, new Rectangle(0, 0, 16, 16), Color.White);
|
spriteBatch.Draw(Textures.Heart.Get, pos, new Rectangle(0, 0, 16, 16), Color.White);
|
||||||
} else {
|
} else {
|
||||||
spriteBatch.Draw(Textures.Heart.Get, pos, new Rectangle(16, 0, 16, 16), Color.White);
|
spriteBatch.Draw(Textures.Heart.Get, pos, new Rectangle(16, 0, 16, 16), Color.White);
|
||||||
|
@ -23,7 +23,6 @@ namespace SemiColinGames {
|
|||||||
int levelIdx = -1;
|
int levelIdx = -1;
|
||||||
|
|
||||||
Scene scene;
|
Scene scene;
|
||||||
Player player;
|
|
||||||
World world;
|
World world;
|
||||||
LinesOfSight linesOfSight;
|
LinesOfSight linesOfSight;
|
||||||
Camera camera = new Camera();
|
Camera camera = new Camera();
|
||||||
@ -68,7 +67,6 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
private void LoadLevel() {
|
private void LoadLevel() {
|
||||||
camera = new Camera();
|
camera = new Camera();
|
||||||
player = new Player();
|
|
||||||
levelIdx++;
|
levelIdx++;
|
||||||
world = new World(Levels.ALL_LEVELS[levelIdx % Levels.ALL_LEVELS.Length]);
|
world = new World(Levels.ALL_LEVELS[levelIdx % Levels.ALL_LEVELS.Length]);
|
||||||
scene?.Dispose();
|
scene?.Dispose();
|
||||||
@ -115,14 +113,9 @@ namespace SemiColinGames {
|
|||||||
if (!paused) {
|
if (!paused) {
|
||||||
float modelTime = (float) gameTime.ElapsedGameTime.TotalSeconds;
|
float modelTime = (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
Clock.AddModelTime(modelTime);
|
Clock.AddModelTime(modelTime);
|
||||||
player.Update(modelTime, input, world.CollisionTargets);
|
world.Update(modelTime, input);
|
||||||
world.Update(modelTime);
|
linesOfSight.Update(world.Player, world.CollisionTargets);
|
||||||
linesOfSight.Update(player, world.CollisionTargets);
|
camera.Update(world.Player.Position, world.Width);
|
||||||
camera.Update(player.Position, world.Width);
|
|
||||||
if (player.Health <= 0) {
|
|
||||||
world = new World(Levels.ALL_LEVELS[levelIdx % Levels.ALL_LEVELS.Length]);
|
|
||||||
player = new Player();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
@ -144,7 +137,7 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
Debug.SetFpsText(fpsText);
|
Debug.SetFpsText(fpsText);
|
||||||
|
|
||||||
scene.Draw(gameTime.IsRunningSlowly, world, player, linesOfSight, paused);
|
scene.Draw(gameTime.IsRunningSlowly, world, linesOfSight, paused);
|
||||||
|
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
drawTimer.Stop();
|
drawTimer.Stop();
|
||||||
|
@ -90,13 +90,14 @@ namespace SemiColinGames {
|
|||||||
public const int TileSize = 16;
|
public const int TileSize = 16;
|
||||||
readonly Tile[] tiles;
|
readonly Tile[] tiles;
|
||||||
readonly Tile[] decorations;
|
readonly Tile[] decorations;
|
||||||
|
|
||||||
readonly NPC[] npcs = new NPC[1];
|
readonly NPC[] npcs = new NPC[1];
|
||||||
|
|
||||||
// Size of World in terms of tile grid.
|
// Size of World in terms of tile grid.
|
||||||
private readonly int tileWidth;
|
private readonly int tileWidth;
|
||||||
private readonly int tileHeight;
|
private readonly int tileHeight;
|
||||||
|
|
||||||
|
public Player Player { get; private set; }
|
||||||
|
|
||||||
// Size of World in pixels.
|
// Size of World in pixels.
|
||||||
public int Width {
|
public int Width {
|
||||||
get { return tileWidth * TileSize; }
|
get { return tileWidth * TileSize; }
|
||||||
@ -107,6 +108,7 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public World(string levelSpecification) {
|
public World(string levelSpecification) {
|
||||||
|
Player = new Player();
|
||||||
npcs[0] = new NPC(new Point(16 * 38, 16 * 12));
|
npcs[0] = new NPC(new Point(16 * 38, 16 * 12));
|
||||||
var tilesList = new List<Tile>();
|
var tilesList = new List<Tile>();
|
||||||
var decorationsList = new List<Tile>();
|
var decorationsList = new List<Tile>();
|
||||||
@ -155,10 +157,18 @@ namespace SemiColinGames {
|
|||||||
new Vector2(Width + 1, 0), new Vector2(1, float.MaxValue));
|
new Vector2(Width + 1, 0), new Vector2(1, float.MaxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(float modelTime) {
|
public void Update(float modelTime, History<Input> input) {
|
||||||
|
Player.Update(modelTime, input, CollisionTargets);
|
||||||
foreach (NPC npc in npcs) {
|
foreach (NPC npc in npcs) {
|
||||||
npc.Update(modelTime);
|
npc.Update(modelTime);
|
||||||
}
|
}
|
||||||
|
if (Player.Health <= 0) {
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset() {
|
||||||
|
Player = new Player();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawBackground(SpriteBatch spriteBatch) {
|
public void DrawBackground(SpriteBatch spriteBatch) {
|
||||||
|
Loading…
Reference in New Issue
Block a user