Yeah. I wrote a game, or atleast I count it as a game at 3am or so last night
First thing I've made with SCAR since ages ago so if it's nubby don't blame me..
Oh yeah and seizure warning, flashing stuff
If you're sensitive make the ballcount smaller and background flashing interval bigger..
The idea of this "game" is to eat the other balls with your blue ball by moving the blue ball over the other "enemy" balls. Control the blue ball with your mouse.
SCAR Code:
//OMGBALLS. Best game ever. Made by GoF`
//eat the other balls with the blue ball.
//Move with the mouse.. ball follows your cursor.
//Flashy stuff.. Seizure warning xD
program OMGBALLS;
const
OtherBC = 85; // How many enemy balls to spawn? Max 155, min 1.
TXT = True; // Show the text ingame?
BGInterval = 125; // Interval (in ms) between background color changes??
// (smaller = faster)
type
Balls = record
Loc: TPoint;
Lx1, Ly1, Lx2, Ly2: Integer; // last size as size changes.. for eat checking
end;
var
OBForm: TForm;
T: TVariantArray;
FCanvas: TCanvas;
BufImg, R, Score, BCTimeout: Integer;
OtherBalls: array of Balls;
BlueBall: Balls;
function ReBornBall: Balls; //remake a ball.
begin
Result.Loc.X := Random(410) + 20;
Result.Loc.Y := Random(410) + 20;
Result.Lx1 := Result.Loc.X;
Result.Ly1 := Result.Loc.Y;
Result.Lx2 := Result.Loc.X;
Result.Ly2 := Result.Loc.Y;
end;
function InBlue(Sx, Sy, Ssx, Ssy: Integer): Boolean; // checks if enemy is in your area
begin
if (Sx < BlueBall.Lx2) and
(Sy < BlueBall.Ly2) and
(Sx > BlueBall.Lx1) and
(Sy > BlueBall.Ly1) then
begin
Result := True;
Exit;
end;
if (Ssx < BlueBall.Lx2) and
(Ssy < BlueBall.Ly2) and
(Ssx > BlueBall.Lx1) and
(Ssy > BlueBall.Ly1) then
Result := True;
end;
var
LastTxt: Integer;
procedure Draw(Sender: TObject); // drawing..
var
Ct: Integer;
DIt: Boolean;
begin
SafeDrawBitmap(BufImg, FCanvas, 0, 0); // black background.
if (TXT) and (LastTxt > 5) then // move and update text every 5 frames.
begin
LastTxt := 1;
with FCanvas do
begin
Font.Name := 'Arial';
Font.Size := 10 + Random(15);
Font.Color := Random(16777215);
TextOut(Random(120), Random(400), 'OMGBALLS - The Game.');
end;
end;
Inc(LastTxt);
for Ct := 0 to High(OtherBalls) do // your worst enemies
begin
DIt := True;
if not InBlue(OtherBalls[Ct].Lx1, OtherBalls[Ct].Ly1, OtherBalls[Ct].Lx2, OtherBalls[Ct].Ly2) then
begin // if not eaten then randomize new size..
OtherBalls[Ct].Lx1 := OtherBalls[Ct].Loc.X - 7 + Random(9);
OtherBalls[Ct].Ly1 := OtherBalls[Ct].Loc.Y - 7 + Random(9);
OtherBalls[Ct].Lx2 := OtherBalls[Ct].Loc.X + 7 + Random(9);
OtherBalls[Ct].Ly2 := OtherBalls[Ct].Loc.Y + 7 + Random(9);
end else
begin // and if eaten...
OtherBalls[Ct] := ReBornBall;
Inc(Score);
ClearDebug;
Writeln('YOU ATE AN ENEMY BALL! CONGRATULATIONS!');
Writeln('Current score: ' + IntToStr(Score) + '!');
DIt := False;
end;
if DIt then
with FCanvas do
begin
Brush.Style := bsSolid;
Brush.Color := Random(16777215);
Pen.Width := 1;
Pen.Color := Random(16777215);
Ellipse(OtherBalls[Ct].Lx1, OtherBalls[Ct].Ly1, OtherBalls[Ct].Lx2, OtherBalls[Ct].Ly2);
end;
end;
BlueBall.Lx1 := BlueBall.Loc.X - 17 + Random(11); // your ball
BlueBall.Ly1 := BlueBall.Loc.Y - 17 + Random(11);
BlueBall.Lx2 := BlueBall.Loc.X + 17 + Random(11);
BlueBall.Ly2 := BlueBall.Loc.Y + 17 + Random(11);
with FCanvas do
begin
Brush.Style := bsSolid;
Brush.Color := clBlue;
Pen.Width := 1;
Pen.Color := clBlue;
Ellipse(BlueBall.Lx1, BlueBall.Ly1, BlueBall.Lx2, BlueBall.Ly2);
end;
end;
procedure MMove(Sender: TObject; Shift: TShiftState; x, y: Integer);
begin
BlueBall.Loc.X := x;
BlueBall.Loc.Y := y;
end;
procedure ChangeBG(Sender: TObject); // new background color
begin
FastDrawClear(BufImg, Random(16777215));
end;
procedure Init; // form
var
Time: TTimer;
Time_: TTimer;
begin
with OBForm do
begin
Width := 450;
Height := 450;
Position := poDefault;
BorderIcons := [biSystemMenu];
BorderStyle := bsSingle;
Caption := 'OMGBALLS - The Game.';
Color := 0;
OnPaint := @Draw;
OnMouseMove := @MMove;
end;
FCanvas := OBForm.Canvas;
Time := TTimer.Create(OBForm);
with Time do
begin
Interval := 29;
OnTimer := @Draw;
end;
Time_ := TTimer.Create(OBForm);
with Time_ do
begin
Interval := BGInterval;
OnTimer := @ChangeBG;
end;
OBForm.ShowModal;
end;
procedure MakeBalls;
var
MBC: Integer;
begin
for MBC := 0 to High(OtherBalls) do
begin
OtherBalls[MBC].Loc.X := Random(410) + 20;
OtherBalls[MBC].Loc.Y := Random(410) + 20;
OtherBalls[MBC].Lx1 := OtherBalls[MBC].Loc.X - 5 + Random(8);
OtherBalls[MBC].Ly1 := OtherBalls[MBC].Loc.Y - 5 + Random(8);
OtherBalls[MBC].Lx2 := OtherBalls[MBC].Loc.X + 5 + Random(8);
OtherBalls[MBC].Ly2 := OtherBalls[MBC].Loc.Y + 5 + Random(8);
end;
BlueBall.Loc.X := 225;
BlueBall.Loc.Y := 225;
end;
procedure StartUp; // startup
begin
ClearDebug;
Writeln('OMGBALLS - The Game. By GoF` ');
Writeln('Have fun.');
Wait(2500);
Score := 0;
OBForm := CreateForm;
BufImg := BitmapFromString(450, 450, '');
FastDrawClear(BufImg, 0);
SetArrayLength(OtherBalls, OtherBC)
MakeBalls;
end;
begin
StartUp;
ThreadSafeCall('Init', T);
end.