program SandwichTrainer;
uses SwinGame, sgTypes, SysUtils;
type
FoodKind = (Bun, Rye, Bbq, Ketchup, Mayo, Mustard, Lettuce, Tomato, Beetroot, Pickles, Strings, None, Chicken, Pork, SaucyBeef, SliceBeef, Pastrami, Tasty, Swiss, Scamorza);
SandwichKind = (Carolina, Dorothy, ZMan, NewYork, Aussie, Kids);
//FoodData = record
// name: FoodKind;
// bmp: Bitmap;
//end;
InputData = record
cheese: array of FoodKind;
toppings: array of FoodKind;
SAndS: Boolean;
end;
TargetData = record
cheese: array of FoodKind;
kind: SandwichKind;
toppings: array of FoodKind;
end;
GameData = record
input: InputData;
target: TargetData;
score: Integer;
currentPanel: String;
end;
procedure LoadResources();
begin
LoadBitmapNamed('BottomBun', 'BottomBun.png');
LoadBitmapNamed('TopBun', 'TopBun.png');
LoadBitmapNamed('Lettuce', 'Lettuce.png');
LoadBitmapNamed('Beetroot', 'Beetroot.png');
LoadBitmapNamed('Tomato', 'Tomato.png');
LoadBitmapNamed('Tasty', 'Tasty.png');
LoadBitmapNamed('Bbq', 'Bbq.png');
LoadBitmapNamed('Ketchup', 'Ketchup.png');
LoadBitmapNamed('Pickles', 'Pickles.png');
end;
function FoodBitmap(input: FoodKind): Bitmap;
begin
case input of
Bbq: result := BitmapNamed('Bbq');
Ketchup: result := BitmapNamed('Ketchup');
Lettuce: result := BitmapNamed('Lettuce');
Tomato: result := BitmapNamed('Tomato');
Beetroot: result := BitmapNamed('Beetroot');
Pickles: result := BitmapNamed('Pickles');
Tasty: result := BitmapNamed('Tasty');
Scamorza: result := BitmapNamed('Scamorza');
end;
end;
procedure DrawSandwich(const game: GameData);
var
i: Integer;
begin
DrawBitmap(BitmapNamed('BottomBun'), Round((ScreenWidth() - BitmapWidth(BitmapNamed('BottomBun'))) / 2), Round((ScreenHeight() - BitmapHeight(BitmapNamed('BottomBun'))) - 20));
DrawBitmap(BitmapNamed('TopBun'), Round((ScreenWidth() - BitmapWidth(BitmapNamed('BottomBun'))) / 2), 10);
for i := 0 to (Length(game.input.toppings) - 1) do
begin
DrawBitmap(FoodBitmap(game.input.toppings[i]), Round((ScreenWidth() - BitmapWidth(FoodBitmap(game.input.toppings[i]))) / 2), Round((ScreenHeight() - BitmapHeight(FoodBitmap(game.input.toppings[i]))) - 20));
end;
for i := 0 to (Length(game.input.cheese) - 1) do
begin
DrawBitmap(FoodBitmap(game.input.cheese[i]), Round((ScreenWidth() - BitmapWidth(FoodBitmap(game.input.cheese[i]))) / 2), 10);
end;
end;
procedure AddTopping(var input: InputData; topping: FoodKind);
begin
SetLength(input.toppings, (Length(input.Toppings) +1));
input.toppings[(Length(input.toppings) -1)] := topping;
end;
procedure AddCheese(var input: InputData; cheese: FoodKind);
begin
SetLength(input.cheese, (Length(input.cheese) + 1));
input.cheese[(Length(input.cheese) + 1)] := cheese;
end;
procedure SauceSelect(var game: gameData);
begin
if ButtonClicked('BbqButton') then
begin
AddTopping(game.input, Bbq);
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.currentPanel := 'SaladPanel';
end;
if ButtonClicked('KetchupButton') then
begin
AddTopping(game.input, Ketchup);
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.currentPanel := 'SaladPanel';
end;
end;
procedure SaladSelect(var game: gameData);
begin
if ButtonClicked('LettuceButton') then
AddTopping(game.input, Lettuce);
if ButtonClicked('BeetrootButton') then
AddTopping(game.input, Beetroot);
if ButtonClicked('TomatoButton') then
AddTopping(game.input, Tomato);
if ButtonClicked('PicklesButton') then
AddTopping(game.input, Pickles);
if ButtonClicked('DoneButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.currentPanel := 'CheesePanel';
end;
end;
procedure CheeseSelect(game: gameData);
begin
if ButtonClicked('TastyButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
AddCheese(game.input, Tasty);
end;
if ButtonClicked('ScamorzaButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
AddCheese(game.input, Scamorza);
end;
end;
procedure AssignTarget(var game: GameData);
begin
case game.target.kind of
Aussie:
begin
SetLength(game.target.toppings, 7);
game.target.toppings[0] := Bbq;
game.target.toppings[1] := Mayo;
game.target.toppings[2] := Lettuce;
game.target.toppings[3] := Beetroot;
game.target.toppings[4] := Tomato;
game.target.toppings[5] := Chicken;
game.target.toppings[6] := None;
game.target.cheese[0] := Tasty;
end;
Dorothy:
begin
SetLength(game.target.toppings, 3);
game.target.toppings[0] := Bbq;
game.target.toppings[1] := Pickles;
game.target.toppings[2] := SaucyBeef;
game.target.cheese[0] := None;
end;
Carolina:
begin
SetLength(game.target.toppings, 3);
game.target.toppings[0] := Bbq;
game.target.toppings[1] := None;
game.target.toppings[2] := Pork;
game.target.cheese[0] := None;
end;
ZMan:
begin
SetLength(game.target.toppings, 3);
game.target.toppings[0] := Bbq;
game.target.toppings[1] := None;
game.target.toppings[2] := SliceBeef;
game.target.cheese[0] := Scamorza;
end;
Kids:
begin
SetLength(game.target.toppings, 4);
game.target.toppings[0] := Ketchup;
game.target.toppings[1] := None;
game.target.toppings[2] := Chicken;
game.target.toppings[3] := None;
game.target.cheese[0] := None;
end;
end;
end;
procedure SandwichSelect(var game: GameData);
begin
if ButtonClicked('AussieButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.target.kind := Aussie;
game.currentPanel := 'SaucePanel';
end;
if ButtonClicked('CarolinaButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.target.kind := Carolina;
game.currentPanel := 'SaucePanel';
end;
if ButtonClicked('DorothyButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.target.kind := Dorothy;
game.currentPanel := 'SaucePanel';
end;
if ButtonClicked('ZManButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.target.kind := ZMan;
game.currentPanel := 'SaucePanel';
end;
if ButtonClicked('KidsButton') then
begin
HidePanel(game.currentPanel);
ClearScreen(ColorWhite);
game.target.kind := Kids;
game.currentPanel := 'SaucePanel';
end;
end;
function CheckResults(game: GameData): Boolean;
var
i: Integer;
begin
for i := 0 to High(game.input.toppings) do
begin
if (game.input.toppings[i] = game.target.toppings[i]) then
result := True
else
result := False;
end;
end;
procedure Main();
var
game: GameData;
begin
OpenAudio();
OpenGraphicsWindow('SandwichTrainer', 1000, 800);
LoadDefaultColors();
LoadResources();
LoadResourceBundle( 'NumberBundle.txt' );
GUISetForegroundColor(ColorBlack);
GUISetBackgroundColor(ColorWhite);
game.currentPanel := 'MenuPanel';
SetLength(game.target.cheese, 1);
SetLength(game.input.cheese, 0);
SetLength(game.input.toppings, 0);
repeat
ProcessEvents();
UpdateInterface();
DrawInterface();
RefreshScreen(60);
ShowPanel(game.currentPanel);
SandwichSelect(game);
AssignTarget(game);
SauceSelect(game);
SaladSelect(game);
CheeseSelect(game);
DrawSandwich(game);
until(WindowCloseRequested());
end;
begin
Main();
end.