Computer Science Canada

Target Shooter

Author:  petree08 [ Thu Nov 02, 2006 12:04 pm ]
Post subject:  Target Shooter

This is a game in witch you have 2 shoot has many targets as you can with the mouse.

I kinda jazzed it up a bit by adding my logo and a tittle screen (that looks kinda old shool)

This is kind of like Methodoxx's target shooter but I didn't even look at his code and thougt it would be challenging to make my own version of it

Have Fun!

code:


const TIME_T := 60
const TARGET_NUM := 10
const C_C := 0
var TimeLeft : int := TIME_T
var IntToString : string
var Font1 : int := Font.New ("Arial:20")
var Font2 : int := Font.New ("System:50")
var Font3 : int := Font.New ("System:140")
var Score : int := 0
var Hitter : boolean
var Pauser : char
var Index2 : nat := 1
var Xm, Ym, Click : int
var Clicker : boolean := false
var X, Y, Dx, Dy : array 1 .. TARGET_NUM of int
var Length : array 1 .. TARGET_NUM of real4
var Hit, Miss : nat1 := 0
var YesNo : string (2)

process Bang
    sound (200, 100)
end Bang

procedure Crosshairs

    drawline (Xm - 30, Ym, Xm - 5, Ym, C_C)
    drawline (Xm + 30, Ym, Xm + 5, Ym, C_C)
    drawline (Xm, Ym - 30, Xm, Ym - 5, C_C)
    drawline (Xm, Ym + 30, Xm, Ym + 5, C_C)

    Draw.ThickLine (Xm - 100, Ym, Xm - 30, Ym, 5, C_C)
    Draw.ThickLine (Xm + 100, Ym, Xm + 30, Ym, 5, C_C)
    Draw.ThickLine (Xm, Ym - 100, Xm, Ym - 30, 5, C_C)
    Draw.ThickLine (Xm, Ym + 100, Xm, Ym + 30, 5, C_C)


    drawoval (Xm, Ym, 100, 100, C_C)
    drawoval (Xm, Ym, 30, 30, C_C)

    drawfilloval (Xm, Ym, 3, 3, 12)


end Crosshairs


procedure Random

    for Index : 1 .. TARGET_NUM
        randint (X (Index), 1, maxx)
        randint (Y (Index), 1, maxy)

        loop
            randint (Dx (Index), -1, 1)
            exit when Dx (Index) not= 0
        end loop
        loop
            randint (Dy (Index), -1, 1)
            exit when Dy (Index) not= 0
        end loop
    end for
end Random
process Timer
    loop
        delay (1000)
        TimeLeft := TimeLeft - 1
        exit when TimeLeft <= 0
    end loop
end Timer

procedure Pause
    Pauser := getchar
end Pause

procedure Logo
    colorback (0)

    cls
    Font.Draw ("W", 300, 300, Font3, 7)
    View.Update
    delay (100)
    Font.Draw ("W", 305, 305, Font3, 4)
    View.Update
    delay (100)
    Font.Draw ("PEE-TORE", 200, 300, Font2, 7)
    View.Update
    delay (100)
    Font.Draw ("PEE-TORE", 205, 305, Font2, 12)
    View.Update
    delay (1000)

    Font.Draw ("**PEE-TORE GAMES**", 200, 100, Font1, 12)
    View.Update
    delay (2000)
end Logo



setscreen ("graphics:max,max,nobuttonbar,offscreenonly")

Logo

colorback (7)
loop
    Random
    cls

    Font.Draw ("DISC SHOOTER", maxx div 2 - 200, maxy - 200, Font2, 12)
    Font.Draw ("**PEE-TORE GAMES** presents: ", 200, maxy - 100, Font1, 12)
    Font.Draw ("(press any key to continue) ", 200, maxy - 300, Font1, 12)
    View.Update
    Pause

    cls
    Font.Draw ("The object of this game is to shoot has many targets as you can"
        , 1, maxy - 50, Font1, 12)
    Font.Draw ("with in the time limit."
        , 1, maxy - 100, Font1, 12)

    Font.Draw ("(press any key to continue)", 1, maxy - 150, Font1, 12)
    View.Update
    Pause

    for decreasing CountDown : 3 .. 0
        cls
        IntToString := intstr (CountDown)

        Font.Draw (IntToString, maxx div 2, maxy div 2, Font1, 12)
        View.Update
        delay (1000)
    end for


    TimeLeft := TIME_T
    Score := 0
    Hit := 0
    Miss := 0
    fork Timer
    loop

        cls




        mousewhere (Xm, Ym, Click)

        for Index : 1 .. TARGET_NUM
            if X (Index) >= maxx or X (Index) <= 1 then
                Dx (Index) := -Dx (Index)
            end if

            if Y (Index) >= maxy or Y (Index) <= 1 then
                Dy (Index) := -Dy (Index)
            end if
            Y (Index) := Y (Index) + Dy (Index)
            X (Index) := X (Index) + Dx (Index)
            drawfilloval (X (Index), Y (Index), 15, 15, 12)
            drawfilloval (X (Index), Y (Index), 10, 10, 0)
            drawfilloval (X (Index), Y (Index), 5, 5, 12)
        end for


        % Shooting and checking if a target was hit

        if Click = 1 and Clicker = false then
            fork Bang
            Index2 := 1
            Clicker := true
            Hitter := false
            loop
                % find length between mouse and targets
                Length (Index2) := sqrt ((X (Index2) - Xm) ** 2 + (Y (Index2) - Ym) ** 2)
                % check if the length is within the range of the radius of the disc
                if Length (Index2) < 15 then

                    Hitter := true % used for to flag if a target was hit
                    Hit := Hit + 1
                    Score := Score + 50
                    randint (X (Index2), 1, maxx)
                    randint (Y (Index2), 1, maxy)
                else
                    Hitter := false
                end if
                exit when Hitter = true or Index2 >= TARGET_NUM %
                Index2 := Index2 + 1  % bumps the target being checked


            end loop
            if Hitter = false then
                Miss := Miss + 1
                Score := Score - 100
            end if
        elsif Click = 0 then
            Clicker := false
        end if
        Crosshairs

        IntToString := intstr (Hit)

        Font.Draw ("Hit :" + IntToString, 10, 10, Font1, C_C)


        IntToString := intstr (Miss)

        Font.Draw ("Miss :" + IntToString, 100, 10, Font1, C_C)
        IntToString := intstr (Score)

        Font.Draw ("Score :" + IntToString, 250, 10, Font1, C_C)

        IntToString := intstr (TimeLeft)

        Font.Draw ("Time left :" + IntToString, 10, maxy - 20, Font1, C_C)



        % put "Hit: ", Hit
        % put "Missed: ", Miss
        % put "Score ", Score

        exit when TimeLeft <= 0
        View.Update
    end loop
    cls

    Font.Draw ("Times Up!", maxx div 2, maxy - 100, Font2, 12)
    IntToString := intstr (Score)

    Font.Draw ("Your score was " + IntToString, maxx div 2, maxy - 200, Font1, 12)


    Font.Draw ("Would you like to play again? (y/n)", maxx div 2 - 100, maxy - 300, Font1, 12)
    View.Update
    get YesNo
    exit when YesNo = "n"
end loop


Author:  jr.ranger.33 [ Sat Nov 04, 2006 4:39 pm ]
Post subject:  No cursor

Pretty good,
Just one thing that i didn't like was the flashing cursor, just put:
setscreen ("nocursor")
at the top of your source code

Author:  warburk [ Thu Dec 07, 2006 11:52 am ]
Post subject:  Hello

Smile [b]It's alitlle bit hard for a first timer to play, but the game is very good and very well made.[/b]

Author:  Clayton [ Fri Dec 08, 2006 10:03 am ]
Post subject: 

Holy necro-post batman! Please don't bring up month old topics unless you have something to add to the thread. Just saying "good game" is not enough to bring up old threads. Please remember this next time you are looking through older topics Very Happy

Author:  lil_darkness_thug [ Tue May 15, 2007 10:16 am ]
Post subject:  RE:Target Shooter

Mm Really cool game

well looks liek you must be turing professional

i need if ye can help me wid one program like i m almost done with it i jus need 2 do the thing when mouse touches the bounsing balls it has 2 execute so ifye can help me wid it that will b great my email is

lil_darkness_thug85@hotmail.com

i'll send you the game if you need it.

Author:  Tallguy [ Fri May 25, 2007 9:51 am ]
Post subject:  Re: Target Shooter

fun, hard, i like it

Author:  Vin90 [ Wed Dec 26, 2007 10:16 pm ]
Post subject:  Re: Target Shooter

Hi, I'm really new to Turing and I'd like to make a shooting game similar to yours, but I want it to be shooting a picture of a monster instead. How do i do that? I want the pics to move around randomly like the little targets. I've tried going through many of the tutorials and also other people's submissions, but I still don't understand how do it. If you don't mind, could you please help me out, or perhaps show me where i can find help on this site. Thanks.

Author:  Sean [ Thu Dec 27, 2007 4:04 pm ]
Post subject:  Re: Target Shooter

I love when people steal your picture.. ^Tall Guy!

Author:  syntax_error [ Thu Dec 27, 2007 8:40 pm ]
Post subject:  Re: Target Shooter

Vin90 wrote:

Hi, I'm really new to Turing and I'd like to make a shooting game similar to yours, but I want it to be shooting a picture of a monster instead. How do i do that? I want the pics to move around randomly like the little targets. I've tried going through many of the tutorials and also other people's submissions, but I still don't understand how do it. If you don't mind, could you please help me out, or perhaps show me where i can find help on this site. Thanks.


firstly let me say if you draw your "monster" something other then turing this may be a more diffcult task then you can imagine
so I advice you to make sure you draw the "monster" in turing and look at how petree08 using vars (not hard number) to draw the targets and then draw them onto the screen ( hint look at the proc random )

@ petree08 I really love it when pll say things like "Methodoxx's target shooter but I didn't even look at his code" why do you assume if the work you know it original that pll will say its someones else work.

....... just a thought

Author:  Vin90 [ Fri Dec 28, 2007 10:08 am ]
Post subject:  Re: Target Shooter

syntax_error @ Thu 27 Dec, 8:40 pm wrote:

firstly let me say if you draw your "monster" something other then turing this may be a more diffcult task then you can imagine
so I advice you to make sure you draw the "monster" in turing and look at how petree08 using vars (not hard number) to draw the targets and then draw them onto the screen ( hint look at the proc random )


Hm.. alrighty, I'll try to look through it again and see if i can figure it out. Thanks for the help though Smile

Author:  Nyrd [ Sun Feb 10, 2008 10:32 pm ]
Post subject:  RE:Target Shooter

That persistently annoying sound just about burst my brain, but apart from that cool game!

Author:  petree08 [ Mon Feb 11, 2008 3:27 pm ]
Post subject:  RE:Target Shooter

Um this was ..

Posted: Thu Nov 02, 2006 12:04 pm

and it's not even good. this topic died a while ago.


: