Skip to content

Commit

Permalink
(#12) tsoccer everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Jun 30, 2022
1 parent 173dbd4 commit 3fc3dd9
Show file tree
Hide file tree
Showing 10 changed files with 543 additions and 0 deletions.
66 changes: 66 additions & 0 deletions LCDonald.Core/GameAssets/tsoccer/tsoccer.lay
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!-- tsoccer.lay -->

<mamelayout version="2">

<!-- Define Elements -->

<element name="manual">
<image file="tsoccer_manual.jpg" />
</element>
<element name="front">
<image file="tsoccer_front.jpg" />
</element>
<element name="back">
<image file="tsoccer_back.jpg" />
</element>
<element name="game_bg_crop">
<image file="tsoccer_bg_crop.jpg" />
</element>
<element name="game_bg">
<image file="tsoccer_bg.jpg" />
</element>

<!-- Define Views -->

<view name="Front">
<screen index="0">
<bounds x="1772" y="579" width="579" height="703" />
</screen>
<element ref="front">
<bounds x="0" y="0" width="3970" height="2600" />
</element>
<element ref="game_bg_crop">
<bounds x="1769" y="574" width="585" height="711" />
</element>
</view>

<view name="Closeup">
<screen index="0">
<bounds x="16" y="28" width="856" height="1040" />
</screen>
<element ref="game_bg">
<bounds x="0" y="0" width="889" height="1122" />
</element>
</view>

<view name="Back">
<element ref="back">
<bounds x="0" y="0" width="3970" height="2600" />
</element>
</view>

<view name="Instructions">
<element ref="manual">
<bounds x="0" y="0" width="432" height="422" />
</element>
</view>
</mamelayout>

<!--
Tails Soccer
- Artwork type: Photo, Background
- McDonald's Sonic Games Assets by Difegue
- Manual taken from Sonic Retro.

-->

249 changes: 249 additions & 0 deletions LCDonald.Core/GameAssets/tsoccer/tsoccer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LCDonald.Core/GameAssets/tsoccer/tsoccer_back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LCDonald.Core/GameAssets/tsoccer/tsoccer_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
227 changes: 227 additions & 0 deletions LCDonald.Core/Games/TailsSoccer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
using LCDonald.Core.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace LCDonald.Core.Games
{
public class TailsSoccer : LCDGameBase
{
public override string ShortName => "tsoccer";
public override string Name => "Tails Soccer (2004)";

#region SVG Group Names
public const string LEVEL_1 = "level-1";
public const string LEVEL_2 = "level-2";
public const string LEVEL_3 = "level-3";
public const string BALL_11 = "ball-11";
public const string BALL_12 = "ball-12";
public const string BALL_13 = "ball-13";
public const string BALL_21 = "ball-21";
public const string BALL_22 = "ball-22";
public const string BALL_23 = "ball-23";
public const string BALL_31 = "ball-31";
public const string BALL_32 = "ball-32";
public const string BALL_33 = "ball-33";
public const string BALL_41 = "ball-41";
public const string BALL_42 = "ball-42";
public const string BALL_43 = "ball-43";
public const string TAILS_LEFT = "tails-left";
public const string TAILS_RIGHT = "tails-right";
public const string TAILS_CENTER = "tails-center";
public const string BALL_MISS = "ball-miss";
#endregion SVG Group Names

public override List<string> GetAllGameElements()
{
return new List<string>()
{
LEVEL_1, LEVEL_2, LEVEL_3,


BALL_11, BALL_12, BALL_13,
BALL_21, BALL_22, BALL_23,
BALL_31, BALL_32, BALL_33,
BALL_41, BALL_42, BALL_43,

TAILS_LEFT, TAILS_CENTER, TAILS_RIGHT,
BALL_MISS,
};
}

public override List<LCDGameInput> GetAvailableInputs()
{
return new List<LCDGameInput>()
{
new LCDGameInput
{
Name = "Left",
Description = "Move Tails Left",
KeyCode = 23, // left
},
new LCDGameInput
{
Name = "Right",
Description = "Move Tails Right",
KeyCode = 25, // right
}
};
}

private int _tailsPosition;
private int _level;

private int _ballsIntercepted;
private int _ballsMissed;

private int _ballPos;

protected override List<string> GetVisibleElements()
{
var elements = new List<string>();

if (_level >= 1)
elements.Add(LEVEL_1);
if (_level >= 2)
elements.Add(LEVEL_2);
if (_level >= 3)
elements.Add(LEVEL_3);

elements.Add(GetTailsElement());

if (_ballPos != -1)
elements.Add("ball-" + _ballPos);

return elements;
}

private string GetTailsElement()
{
if (_tailsPosition == 1)
return TAILS_LEFT;
else if (_tailsPosition == 2)
return TAILS_CENTER;
else if (_tailsPosition == 3)
return TAILS_RIGHT;

return "";
}

public override void InitializeGameState()
{
_tailsPosition = 2;
_level = 0;

_ballsIntercepted = 0;
_ballsMissed = 0;

_ballPos = -1;

_customUpdateSpeed = 500;
StartupMusic();
}

public override void HandleInputs(List<LCDGameInput> pressedInputs)
{
foreach (var input in pressedInputs)
{
if (input == null) continue;

if (input.Name == "Left" && _tailsPosition > 1)
{
_tailsPosition--;
}
else if (input.Name == "Right" && _tailsPosition < 3)
{
_tailsPosition++;
}
}
}

protected override void UpdateCore()
{
// Unused in this game
}

public override void CustomUpdate()
{
if (_ballsIntercepted == 15)
{
QueueSound(new LCDGameSound("../common/level_up.ogg"));
_ballsIntercepted = 0;
_ballsMissed = 0;
_level++;
// Speed up
_customUpdateSpeed -= 75;
}

if (_level == 4)
{
Victory();
return;
}

if (_ballPos != -1)
{
_ballPos += 10;

if (_ballPos > 50)
{
var digit = _ballPos % 10;
_ballPos = -1;
if (digit == _tailsPosition)
{
_ballsIntercepted++;
QueueSound(new LCDGameSound("../common/hit.ogg"));
}
else
{
_ballsMissed++;
BlinkElement(BALL_MISS, 1);
QueueSound(new LCDGameSound("../common/miss.ogg"));
}

if (_ballsMissed == 5)
GameOver();
}
else if (_ballPos < 40)
{
// Randomly shift ball left or right
var shift = _rng.Next(-1, 2);
_ballPos += shift;

// Adjust out of bounds
if (_ballPos % 10 == 0)
_ballPos++;

if (_ballPos % 10 == 4)
_ballPos--;
}

}
else
{
// Randomly spawn ball at 11, 12 or 13
_ballPos = _rng.Next(11, 14);
}
}

private void GameOver()
{
_tailsPosition = -1;
_ballPos = -1;

GenericGameOverAnimation(new List<string> { BALL_MISS, TAILS_CENTER });
Stop();
}

private void Victory()
{
_tailsPosition = -1;
_ballPos = -1;

GenericVictoryAnimation(new List<string> { LEVEL_1, LEVEL_2, LEVEL_3 });
Stop();
}
}
}
Binary file added LCDonald/Assets/Icons/tsoccer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions LCDonald/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public MainWindowViewModel()
new SonicSpeedway(),
new AiAiBananaCatch(),
new SonicExtremeBoarding(),
new TailsSoccer(),
new SonicSkateboard(),
new AmyRougeTennis(),
new TailsSkyAdventure()
Expand Down

0 comments on commit 3fc3dd9

Please sign in to comment.