program SandwichTrainer;
uses SwinGame, sgTypes, SysUtils;
type
FoodKind = (Bun, Rye, DorothyS, Ketchup, Mayo, Mustard, Lettuce, Tomato, Beetroot, Pickles, Slaw, Strings, None, Chicken, Pork, SaucyBeef, SliceBeef, Pastrami, CAndL, Tasty, Swiss, Scamorza);
SandwichKind = (Carolina, Dorothy, ZMan, NewYork, Aussie, TwoMeat, Kids);
BaseData = record
name: FoodKind;
topBmp: Bitmap;
botBmp: Bitmap;
end;
//FoodData = record
// name: FoodKind;
// bmp: Bitmap;
//end;
InputData = record
base: BaseData;
toppings: array of FoodKind;
SAndS: Boolean;
end;
TargetData = record
base: BaseData;
toppings: array of FoodKind;
SAndS: Boolean;
end;
GameData = record
input: InputData;
target: TargetData;
score: Integer;
end;
procedure LoadResources();
begin
LoadBitmapNamed('BottomBun', 'BottomBun.png');
LoadBitmapNamed('TopBun', 'TopBun.png');
LoadBitmapNamed('Rye', 'RyeBread.png');
LoadBitmapNamed('Lettuce', 'Lettuce.png');
end;
function BunBitmap(var base: BaseData): BaseData;
begin
result.name := base.name;
case base.name of
Bun: begin
result.topBmp := BitmapNamed('TopBun');
result.botBmp := BitmapNamed('BottomBun');
end;
Rye: begin
result.topBmp := BitmapNamed('Rye');
result.botBmp := BitmapNamed('Rye');
end;
end;
end;
function FoodBitmap(input: FoodKind): Bitmap;
begin
case input of
DorothyS: result := BitmapNamed('DorothyS');
Ketchup: result := BitmapNamed('Ketchup');
Mayo: result := BitmapNamed('Mayo');
Mustard: result := BitmapNamed('Mustard');
Lettuce: result := BitmapNamed('Lettuce');
Tomato: result := BitmapNamed('Tomato');
Beetroot: result := BitmapNamed('Beetroot');
Pickles: result := BitmapNamed('Pickles');
Slaw: result := BitmapNamed('Slaw');
Strings: result := BitmapNamed('Strings');
end;
end;
procedure DrawBun(const base: BaseData);
begin
DrawBitmap(base.topBmp, Round((ScreenWidth() - BitmapWidth(base.topBmp)) / 2), 10);
DrawBitmap(base.botBmp, Round((ScreenWidth() - BitmapWidth(base.botBmp)) / 2), Round((ScreenHeight() - BitmapHeight(base.botBmp)) - 20));
RefreshScreen(60);
end;
procedure DrawSandwich(const input: InputData);
var
i: Integer;
begin
for i := 0 to Length(input.toppings) do
begin
DrawBitmap(FoodBitmap(input.toppings[i]), Round((ScreenWidth() - BitmapWidth(FoodBitmap(input.toppings[i]))) / 2), Round((ScreenHeight() - BitmapHeight(FoodBitmap(input.toppings[i]))) - 20));
end;
end;
procedure BunSelect(var input: InputData);
begin
repeat
ProcessEvents();
UpdateInterface();
HidePanel('MenuPanel');
ShowPanel('BreadPanel');
DrawInterface();
RefreshScreen(60);
if ButtonClicked('BunButton') then
begin
input.base.name := Bun;
end;
if ButtonClicked('RyeButton') then
begin
input.base.name := Rye;
end;
until(WindowCloseRequested() or ButtonClicked('BunButton') or ButtonClicked('RyeButton'));
DrawBun(BunBitmap(input.base));
end;
procedure SaladSelect(var input: InputData);
var
i: Integer;
begin
SetLength(input.toppings, 0);
repeat
ProcessEvents();
UpdateInterface();
HidePanel('BreadPanel');
ShowPanel('SaladPanel');
DrawInterface();
RefreshScreen(60);
if ButtonClicked('LettuceButton') then
begin
SetLength(input.toppings, (Length(input.Toppings) +1));
input.toppings[0] := Lettuce;
end;
DrawSandwich(input);
until WindowCloseRequested();
end;
procedure SandwichSelect(var game: GameData);
begin
repeat
ProcessEvents();
UpdateInterface();
if ButtonClicked('AussieButton') then
begin
SetLength(game.target.toppings, 8);
game.target.base.name := Bun;
game.target.toppings[0] := DorothyS;
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.SAndS := True;
game.target.toppings[6] := None;
game.target.toppings[7] := Tasty;
end;
if ButtonClicked('DorothyButton') then
begin
SetLength(game.target.toppings, 5);
game.target.base.name := Bun;
game.target.toppings[0] := DorothyS;
game.target.toppings[1] := Pickles;
game.target.toppings[2] := SaucyBeef;
game.target.SAndS := False;
game.target.toppings[3] := Slaw;
game.target.toppings[4] := None;
end;
if ButtonClicked('CarolinaButton') then
begin
SetLength(game.target.toppings, 5);
game.target.base.name := Bun;
game.target.toppings[0] := DorothyS;
game.target.toppings[1] := None;
game.target.toppings[2] := Pork;
game.target.SAndS := True;
game.target.toppings[3] := Slaw;
game.target.toppings[4] := None;
end;
if ButtonClicked('ZManButton') then
begin
SetLength(game.target.toppings, 5);
game.target.base.name := Bun;
game.target.toppings[0] := DorothyS;
game.target.toppings[1] := None;
game.target.toppings[2] := SliceBeef;
game.target.SAndS := True;
game.target.toppings[3] := Strings;
game.target.toppings[4] := Scamorza;
end;
if ButtonClicked('NewYorkButton') then
begin
SetLength(game.target.toppings, 5);
game.target.base.name := Rye;
game.target.toppings[0] := Mustard;
game.target.toppings[1] := Pickles;
game.target.toppings[2] := Pastrami;
game.target.SAndS := True;
game.target.toppings[3] := Slaw;
game.target.toppings[4] := Swiss;
end;
if ButtonClicked('KidsButton') then
begin
SetLength(game.target.toppings, 5);
game.target.base.name := Bun;
game.target.toppings[0] := Ketchup;
game.target.toppings[1] := None;
game.target.toppings[2] := Chicken;
game.target.SAndS := True;
game.target.toppings[3] := None;
game.target.toppings[4] := None;
end;
if ButtonClicked('TwoMeatButton') then
begin
SetLength(game.target.toppings, 6);
game.target.base.name := Bun;
game.target.toppings[0] := DorothyS;
game.target.toppings[1] := Lettuce;
game.target.toppings[2] := Tomato;
game.target.toppings[3] := CAndL;
game.target.SAndS := True;
game.target.toppings[4] := None;
game.target.toppings[5] := None;
end;
DrawInterface();
RefreshScreen(60);
until(ButtonClicked('AussieButton') or WindowCloseRequested());
end;
procedure Main();
var
game: GameData;
begin
OpenAudio();
OpenGraphicsWindow('SandwichTrainer', 1000, 800);
LoadDefaultColors();
LoadResources();
LoadResourceBundle( 'NumberBundle.txt' );
GUISetForegroundColor( ColorBlack );
GUISetBackgroundColor( ColorWhite );
ClearScreen(ColorWhite);
ShowPanel('MenuPanel');
//Setup(gameData);
SandwichSelect(game);
BunSelect(game.input);
SaladSelect(game.input);
end;
begin
Main();
end.