Skip to content

Commit

Permalink
Implement the win level tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
timotei committed Sep 17, 2011
1 parent e4ab6d5 commit 94f1adf
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 37 deletions.
3 changes: 1 addition & 2 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ Credits for the used resources:
- Main menu background: http://camilkuo.deviantart.com/art/Magic-Forest-25216616
- Main menu frame: http://gearstock.deviantart.com/art/gearstock-old-photo-frame-4492918?q=boost%3Apopular%20old%20frame&qo=15
- Maps: http://www.spriters-resource.com/snes/zeldalinkpast/ , ``Backgrounds & Maps" category
- Main menu font: http://www.fontspace.com/fontgrube/trinigan-fg

- Main menu font: http://www.fontspace.com/fontgrube/trinigan-fg
4 changes: 2 additions & 2 deletions egp_story/Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Assets
public static Texture2D HowToPlayBackground { get; private set; }

public static Texture2D WorldMapTexture { get; private set; }
public static Texture2D Dot { get; private set; }
public static Texture2D Cross { get; private set; }

public static Texture2D HarapAlbShootSouth { get; private set; }
public static Texture2D HarapAlbShootNorth { get; private set; }
Expand Down Expand Up @@ -80,7 +80,7 @@ public static void LoadAssets( ContentManager content )

WorldMapTexture = content.Load<Texture2D>( "gfx/WorldMap" );

Dot = content.Load<Texture2D>( "gfx/dot" );
Cross = content.Load<Texture2D>( "gfx/cross" );

HarapAlbShootSouth = content.Load<Texture2D>( "gfx/harapalb/shoot_s" );
HarapAlbShootNorth = content.Load<Texture2D>( "gfx/harapalb/shoot_n" );
Expand Down
4 changes: 2 additions & 2 deletions egp_story/Levels/Calipuirr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace egp_story.Levels
{
public class Calipuirr : StoryLevel
{
public Calipuirr( Game game )
: base( game )
public Calipuirr( Game game, int index )
: base( game, index )
{
Player player = Player.CreateNewHarapAlb( game );
Enemy bugEnemy = Enemy.CreateBugEnemy( game );
Expand Down
4 changes: 2 additions & 2 deletions egp_story/Levels/EllyuteionLake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace egp_story.Levels
{
public class EllyuteionLake : StoryLevel
{
public EllyuteionLake( Game game )
: base( game )
public EllyuteionLake( Game game, int index )
: base( game, index )
{
Player player = Player.CreateNewHarapAlb( game );
Enemy bugEnemy = Enemy.CreateBugEnemy( game );
Expand Down
4 changes: 2 additions & 2 deletions egp_story/Levels/MirrosHills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace egp_story.Levels
{
public class MirrosHills : StoryLevel
{
public MirrosHills( Game game )
: base( game )
public MirrosHills( Game game, int index )
: base( game, index )
{
Player player = Player.CreateNewHarapAlb( game );
Enemy bugEnemy = Enemy.CreateBugEnemy( game );
Expand Down
4 changes: 2 additions & 2 deletions egp_story/Levels/Pandorashys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace egp_story.Levels
{
public class Pandorashys : StoryLevel
{
public Pandorashys( Game game )
: base( game )
public Pandorashys( Game game, int index )
: base( game, index )
{
Player player = Player.CreateNewHarapAlb( game );
Enemy bugEnemy = Enemy.CreateBugEnemy( game );
Expand Down
12 changes: 7 additions & 5 deletions egp_story/Levels/StoryLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ namespace egp_story.Levels
public abstract class StoryLevel : IUpdateable, IDrawable
{
public bool LevelEnded { get; protected set; }
public bool Won { get; protected set; }
public LevelMap LevelMap { get; protected set; }
public Game Game { get; protected set; }
public int LevelIndex { get; protected set; }

protected bool _gameEnded;
protected bool _won;

public StoryLevel( Game game )
public StoryLevel( Game game, int index )
{
Game = game;
LevelIndex = index;
}

#region IUpdateable Members
Expand All @@ -45,8 +47,8 @@ public virtual void Update( GameTime gameTime )
LevelMap.ThePlayer.IsDead ) {
_gameEnded = true;

_won = !LevelMap.ThePlayer.IsDead;
if ( _won ) {
Won = !LevelMap.ThePlayer.IsDead;
if ( Won ) {
LevelMap.Tint = Color.Yellow;
}
else {
Expand Down Expand Up @@ -80,7 +82,7 @@ public virtual void Draw( SpriteBatch spriteBatch, GameTime gameTime )
LevelMap.Draw( spriteBatch, gameTime );

if ( _gameEnded ) {
spriteBatch.Draw( _won ? Assets.WinMessage : Assets.LoseMessage, new Vector2( 0, 100 ) );
spriteBatch.Draw( Won ? Assets.WinMessage : Assets.LoseMessage, new Vector2( 0, 100 ) );
}
}

Expand Down
4 changes: 2 additions & 2 deletions egp_story/Levels/ViridesPuirr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace egp_story.Levels
{
public class ViridesPuirr : StoryLevel
{
public ViridesPuirr( Game game )
: base( game )
public ViridesPuirr( Game game, int index )
: base( game, index )
{
Player player = Player.CreateNewHarapAlb( game );
Enemy bugEnemy = Enemy.CreateBugEnemy( game );
Expand Down
33 changes: 24 additions & 9 deletions egp_story/Menus/MapMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class MapMenu : Menu
new Vector2( 226, 200 )
};
private const float VIEW_OFFSET = 50f;
public static bool[] WON_STATUSES = new bool[LOCATIONS.Length];

private int _currentLocation;
private Rectangle _targetRectangle;
Expand All @@ -38,6 +39,11 @@ public MapMenu( Game game )
{
_targetRectangle = new Rectangle( 0, 0, TheStory.GAME_WIDTH, Assets.WorldMapTexture.Height );
_currentLocation = 0;
foreach ( bool status in WON_STATUSES ) {
if ( status == true ) {
_currentLocation = ( _currentLocation + 1 ) % LOCATIONS.Length;
}
}
}

#region Menu Members
Expand All @@ -54,12 +60,13 @@ public override void Update( GameTime gameTime )
_targetRectangle.Y = ( int ) MathHelper.Clamp( _targetRectangle.Y,
TheStory.GAME_HEIGHT - Assets.WorldMapTexture.Height, 0 );

int prevLocation = _currentLocation;
// select location
if ( Keyboard.GetState( ).IsKeyDown2( Keys.Left ) ) {
_currentLocation = ( _currentLocation - 1 ) % LOCATIONS.Length;
--_currentLocation;
}
else if ( Keyboard.GetState( ).IsKeyDown2( Keys.Right ) ) {
_currentLocation = ( _currentLocation + 1 ) % LOCATIONS.Length;
++_currentLocation;
}

_currentLocation = ( int ) MathHelper.Clamp( _currentLocation, 0, LOCATIONS.Length - 1 );
Expand All @@ -86,11 +93,11 @@ public override void Update( GameTime gameTime )

if ( Keyboard.GetState( ).IsKeyDown2( Keys.Enter ) ) {
switch ( _currentLocation ) {
case 0: SelectedLevel = new ViridesPuirr( Game ); break;
case 1: SelectedLevel = new Calipuirr( Game ); break;
case 2: SelectedLevel = new EllyuteionLake( Game ); break;
case 3: SelectedLevel = new MirrosHills( Game ); break;
case 4: SelectedLevel = new Pandorashys( Game ); break;
case 0: SelectedLevel = new ViridesPuirr( Game, 0 ); break;
case 1: SelectedLevel = new Calipuirr( Game, 1 ); break;
case 2: SelectedLevel = new EllyuteionLake( Game, 2 ); break;
case 3: SelectedLevel = new MirrosHills( Game, 3 ); break;
case 4: SelectedLevel = new Pandorashys( Game, 4 ); break;
default: break;
}
}
Expand All @@ -101,9 +108,17 @@ public override void Draw( SpriteBatch spriteBatch, GameTime gameTime )
{
spriteBatch.Draw( Assets.WorldMapTexture, _targetRectangle, Color.White );

// draw completed levels
for ( int i = 0; i < LOCATIONS.Length; ++i ) {
if ( WON_STATUSES[i] == true ) {
spriteBatch.Draw( Assets.Cross, LOCATIONS[i] + new Vector2( 0, _targetRectangle.Y ),
Assets.Cross.Bounds.Center.ToVector2( ), Color.Yellow );
}
}

// draw the location
spriteBatch.Draw( Assets.Dot, LOCATIONS[_currentLocation] + new Vector2( 0, _targetRectangle.Y ),
Assets.Dot.Bounds.Center.ToVector2( ) );
spriteBatch.Draw( Assets.Cross, LOCATIONS[_currentLocation] + new Vector2( 0, _targetRectangle.Y ),
Assets.Cross.Bounds.Center.ToVector2( ), Color.Red );
}
#endregion
}
Expand Down
8 changes: 6 additions & 2 deletions egp_story/TheStory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ protected override void Update( GameTime gameTime )
_currentLevel.Update( gameTime );

if ( _currentLevel.LevelEnded ) {
if ( _currentLevel.Won ) {
MapMenu.WON_STATUSES[_currentLevel.LevelIndex] = true;
}
_currentMenu = new MapMenu( this );
_currentLevel = null;
}
}
Expand All @@ -76,9 +80,9 @@ protected override void Update( GameTime gameTime )
if ( _currentMenu.SelectedLevel != null ) {
_currentLevel = _currentMenu.SelectedLevel;
_currentMenu.SelectedLevel = null;
_currentMenu = null;
}

if ( _currentMenu.SelectedMenu != null ) {
else if ( _currentMenu.SelectedMenu != null ) {
_currentMenu = _currentMenu.SelectedMenu;
_currentMenu.SelectedMenu = null;
}
Expand Down
14 changes: 7 additions & 7 deletions egp_storyContent/egp_storyContent.contentproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="gfx\dot.png">
<Name>dot</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="gfx\mobs\bug_walk_e.png">
<Name>bug_walk_e</Name>
Expand Down Expand Up @@ -231,6 +224,13 @@
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="gfx\cross.png">
<Name>cross</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file added egp_storyContent/gfx/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed egp_storyContent/gfx/dot.png
Binary file not shown.

0 comments on commit 94f1adf

Please sign in to comment.