Results 1 to 11 of 11

Thread: SCAR game - click it

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default SCAR game - click it

    this is my first scar game, im still trying to get used to canvases and such

    i got the idea from cazax's click it game in the games folder in scar

    and i got some code from yakman's, and solemn's tuts, so i have to give them some credit

    goal: click the black box as many times as you can within 30 seconds

    every thing else is explained in the script.

    SCAR Code:
    program Akwardsawclickit;

    var Buffer,Line,x, y, a, b, m :integer;

    //thanks to cazax for creating ClickEm - gave me the idea
    //and yakman, and solemn for creating tuts on canvases :D

    //instructions: hit play, and click the black box as many times as you can within
    // 30 seconds. clicking the white area decreases your score!

    procedure draw;
    begin
      Line:=BitmapFromString(10 + random(40),10 + random(40),'');
      FastDrawClear(Buffer,16777215);
      FastDrawTransparent(0 + random(300),y + random(300),Line,Buffer);
      SafeDrawBitmap(Buffer,getdebugcanvas,0,0);
      wait(10);
    end;

    var time: integer;

    procedure check;
    begin
      if IsMouseButtonDown(true) then
      begin
        getmousepos(a, b);
        while IsMouseButtonDown(true) do wait(10);
        if getcolor(a, b) = 0 then inc(m) else dec(m);
        draw;
      end;
    end;

    begin
      Buffer:=BitmapFromString(400,400,'');
      FastDrawClear(Line,0);
      DisplayDebugImgWindow(400,400);
      m := 1;
      time:= GetSystemTime;
      repeat
        check;
        disguise('Clicks: ' + inttostr(m));
      until (getsystemtime - time) > 30000;
      writeln('You have got: ' + inttostr(m) + ' Clicks!');
    end.

    enjoy also post feedback, and ways to make it better so i can be more edumacated
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    You have got: 318 Clicks!

    And no, I did not edit that number in the slightest.

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    SCAR Code:
    begin
      repeat
        findcolor(x, y, 0, x1, y1, x2, y2);
        clickmouse(x, y, true);
        wait(10);
      until false;
    end.
    ? haha
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    SCAR Code:
    begin
      repeat
        findcolor(x, y, 0, x1, y1, x2, y2);
        clickmouse(x, y, true);
        wait(10);
      until false;
    end.
    ? haha
    <.< >.> Maaaaaybe.

  5. #5
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    so uh, hows the script itsself?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  6. #6
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Well, it works well for what it is. But it is rather dull. Try having it generate random colors, or something like that, instead of just black all the time.

  7. #7
    Join Date
    Oct 2006
    Location
    United States
    Posts
    672
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    add something like click the red one, and theres like a red, pink, orange, and yellow one, and theres like a 3 second timer

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    thats just like cazax's though i'm working on different colors though atm
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Apr 2006
    Location
    I live in NH
    Posts
    611
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Cool game. I modified it a bit so the objects are different colors and the code seems more understandable.

    Code:
    //thanks to cazax for creating ClickEm - gave me the idea
    //and yakman, and solemn for creating tuts on canvases :D
    
    //instructions: hit play, and click the black box as many times as you can within
    // 30 seconds. clicking the white area decreases your score!
    
    {
     to do:
      + make rectangles different colors
      - statistics, how many hit and how many missed
      - work TCanvas into script
        - display score on canvas
        - display seconds remaining
      - replace rectangle with an image of a target
      - display more than 1 object at a time
      - make objects move
        - move in patterns with multiple objects
      - even better, make a form and then set a drawing area and put the
      game there
        - buttons to restart game
        - high scores
      - ending animation after clicking objects
    }
    program AkwardsawClickitAndModdedByRon;
    
    const
      // # of seconds to play the game
      PlayTime = 30;
      // miscellaneous
      GameWidth = 400;
      GameHeight = 400;
      BackgroundColor = 16777215;
    
    var
      Buffer, Line, Time, Score, secPlayTime, LineColor : Integer;
      //Canvas : TCanvas;
    
    // displays score, hopefully later it will show the score on the debug image
    procedure ShowScore;
    begin
      Disguise('Score: ' + IntToStr(Score));
    end;
    
    // creates an object at a certain x and y
    // -1, -1 will make the object appear in a random spot
    procedure CreateObject(x, y : Integer);
    begin
      Line := BitmapFromString(10 + Random(40), 10 + Random(40), '');
      FastDrawClear(Buffer, BackgroundColor);
      if ( x = -1 ) and ( y = -1 ) then // if x and y are -1 then randomize x and y
      begin
        x := Random(GameWidth);
        y := Random(GameHeight);
        WriteLn('Drawn at (' + IntToStr(x) + ', ' + IntToStr(y) + ').');
      end;
      // random color
      LineColor := RGBToColor(Random(225), Random(225), Random(225));
      FastDrawClear(Line, LineColor);
      FastDrawTransparent(x, y, Line, Buffer);
      FreeBitmap(Line);
      SafeDrawBitmap(Buffer, GetDebugCanvas, 0, 0);
      //SafeDrawBitmap(Buffer, Canvas, 0, 0);
    end;
    
    // Adds 1 to score if the object is clicked, if not then subtracts 1
    // Creates a new object
    procedure ObjectClicked;
    var
      a, b : Integer;
    begin
      GetMousePos(a, b);
      while IsMouseButtonDown(True) do
        Wait(10);
      if (GetColor(a, b) = LineColor) then
        Inc(Score)
      else
        Dec(Score);
      ShowScore;
      //Canvas.TextOut(0, 0, 'Hey');
      CreateObject(-1, -1); // -1, -1 will randomize the obj's x and y location
    end;
    
    // sets up variables, buffer, and the canvas
    procedure Setup;
    begin
      secPlayTime := PlayTime * 1000;
      Buffer := BitmapFromString(GameWidth, GameHeight, '');
      FastDrawClear(Buffer, BackgroundColor);
      //Canvas := GetDebugCanvas;
      DisplayDebugImgWindow(GameWidth, GameHeight);
      Time := GetSystemTime;
      Score := 1;
    end;
    
    begin
      ClearDebug;
      Setup;
      GetSelf.WindowState := wsMinimized;
      repeat
        if( IsMouseButtonDown(True) ) then
          ObjectClicked;
      until ((GetSystemTime - Time) > secPlayTime) or (IsFKeyDown(12));
      GetSelf.WindowState := wsNormal;
      WriteLn('Your score is ' + IntToStr(Score) + '.');
    end.
    What do you think?

    ~Ron
    DFM Form Parser - SCAR Obfuscator - Master Keylogger - RuneScape Stats Grabber - Index Cards

  10. #10
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I recommend you to use Canvas.Rectangle procedure to make the rectangles so you don't need to load and free bitmaps. If you want color use Canvas.Brush so they will appear with colors. The game in the SCAR folder is the first version, here is the second one:
    scar Code:
    program ClickEm;

    Var
      Canvas : TCanvas;
      C, CurrScore, Background, T, Timer : Integer;

    Function RColor: Integer;
    Begin
      Result := Random(ClWhite);
    End;

    Procedure DrawSquare;
    Var
      Rw, Rh, Col : Integer;
    Begin
      Col := RColor;
      Rh := Random(390) + 100;
      Rw := Random(390) + 20;
      GetDebugCanvas.Brush.Color := RColor;
      Case Random(2) Of
        0: getDebugCanvas.Rectangle((Rh - 1) - Random(20), (Rw - 1) - Random(20), (Rh + 1) + Random(20), (Rw + 1) + Random(20));
        1: getDebugCanvas.Ellipse((Rh - 1) - Random(20), (Rw - 1) - Random(20), (Rh + 1) + Random(20), (Rw + 1) + Random(20));
      End;
    End;

    Procedure ClearScreen;
    Var
      BmpCanv : TCanvas;
    Begin
      BmpCanv := GetBitmapCanvas(BackGround);
      SafeCopyCanvas(BmpCanv, GetDebugCanvas, 0, 0, 499, 499, 1, 13, 499, 499);
    End;

    Procedure DelScore;
    Begin
      SafeCopyCanvas(GetBitmapCanvas(Background), GetDebugCanvas, 0, 0, 150, 20, 0, 0, 150, 20);
    End;

    Procedure DebugScore(Score : Integer);
    Var
      W, H : Integer;
    Begin
      DelScore;
      Score := CreateBitmapMaskFromText('Your Score: ' + IntToStr(Score), UpChars);
      GetBitmapSize(Score, W, H);
      SafeCopyCanvas(GetBitmapCanvas(Score), Canvas, 0, 0, W, H, 0, 0, W, H);
      FreeBitmap(Score);
    End;

    Procedure Winner;
    Begin
      DebugScore(CurrScore);
      ClearScreen;
      DrawSquare;
    End;

    function GetLValue(Color : TColor): Integer;
    Var
       H, S, L : Extended;
    Begin
      ColorToHSL(Color, H, S, L);
      Result := Round(L);
    End;

    Procedure OnClick(Proc : Procedure);
    Var
      X, Y : Integer;
    Begin
      GetMousePos(X, Y);
      If GetColor(X, Y) = 0 Then
        Exit;
      If (X < 0) Or (Y < 0) Or (X > 399) Or (Y > 459) Then //No Cheats
        Exit;
      IncEx(C, GetLValue(GetColor(X, Y)));
      CurrScore := CurrScore + C;
      Proc();
      C := 0;
    End;

    Procedure CheckIt;
    Begin
      OnClick(@Winner);
    End;

    begin
      DisplayDebugImgWindow(500, 500);
      FindWindow('Debug Image');
      Canvas := GetDebugCanvas;
      Background := BitmapFromString(499, 499, '');
      SafeCopyCanvas(GetBitmapCanvas(Background), Canvas, 0, 0, 499, 499, 0, 0, 499, 499);
      T := GetTickCount;
      DrawSquare;
      Repeat
        Timer := GetTickCount;
        While GetTickCount - Timer < 751 Do
        Begin
          CheckIt;
          Wait(33);
        End;
        ClearScreen;
        DrawSquare;
      Until (GetTickCount - T) >= 30000;
      FreeBitmap(Background);
      Writeln('Your score was: ' + IntToStr(CurrScore));
    end.
    And this was the post of the update:
    Quote Originally Posted by Cazax
    New version is out, faster canvas drawing. Now it won't only show squares, can show rectangles, circles and squares. Now the score is based on the color luminance, so the brightest a color is, the highest score you will get. No more color cheaters()! please try it out
    Good luck with yours!


  11. #11
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    oo thanks for the feed back guys i'm interested in updating this.. i'll take a look at both you yours right now
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •