Computer Science Canada

Face Shooter

Author:  Prince Pwn [ Mon May 12, 2008 1:12 pm ]
Post subject:  Face Shooter

I made this probably a year ago. It's really pointless, but I like the shaking/sound effects and 'bullet time'.

Turing:

% Shooter by Drew Martell

View.Set ("graphics,offscreenonly")
Mouse.ButtonChoose ("multibutton")
var xAxis, yAxis, bulletX, bulletY, button, sx, sy := 1 %starting variables
var ballx, bally := Rand.Int (100, 300) %starting location
var bullets, ammo := 2000 %sets amunition and max ammo
var rad := 10 %radius of ball
var score := 0 %how many times you hit the ball
var last : boolean %checks if right click is held
var scope := blue %colour of the scope
var line := black %lines of scope
var ballc := 47 %ball starting colour

process Sound %sound of walls
    Music.Sound (100, 70)
    Music.SoundOff
end Sound

procedure Background %refreshes background
    drawfillbox (0, 0, maxx, maxy, 11)
    drawbox (0, 0, maxx, maxy, black)
    drawfillbox (0, 50, maxx, 0, 49)
    drawbox (0, 50, maxx, 0, black)
    drawdot (bulletX, bulletY, black)
end Background

procedure Ball %ball to shoot
    drawfilloval (round (ballx), round (bally), rad, rad, ballc)     %ball body
    drawoval (round (ballx), round (bally), rad, rad, black)         %ball outline
    drawfilloval (round (ballx) - 3, round (bally) + 2, 1, 1, black)     %left eye
    drawfilloval (round (ballx) + 3, round (bally) + 2, 1, 1, black)     %right eye
    drawfillarc (round (ballx), round (bally) - 2, 2, 4, 180, 360, black)     %smile
    drawfilloval (round (ballx), round (bally), rad, rad, ballc)         %ball body
    drawoval (round (ballx), round (bally), rad, rad, black)         %ball outline
    drawfilloval (round (ballx) - 3, round (bally) + 2, 1, 1, black)     %left eye
    drawfilloval (round (ballx) + 3, round (bally) + 2, 1, 1, black)     %right eye
    drawfillarc (round (ballx), round (bally) - 2, 2, 4, 180, 360, black)     %smile
end Ball

loop %main program loop
    Mouse.Where (xAxis, yAxis, button) %detects mouse location
    Background %refreshes background
    Ball %draws ball

    %increases bouncy ball
    ballx += sx
    bally += sy

    %detemines boundaries and reflects
    if (bally = rad) or (bally = maxy - rad) then
        sy := -sy
        fork Sound
    elsif (ballx = rad) or (ballx = maxx - rad) then
        sx := -sx
        fork Sound
    end if

    if (button = 0) then   %checks for mouse status
        last := false
    end if

    if (button = 1) and (last = true) then   %checks for right click then left click
        Music.Sound (75, 25)
        delay (5)
        Music.Sound (35, 25)
        delay (5)
        Music.SoundOff
       
        bullets -= 7 %depletes your ammo
        bulletX := xAxis
        bulletY := yAxis
       
        %shakes new scope
        var shock := Rand.Int (-5, 5)
        var shock2 := Rand.Int (-3, 3)

        %draws new scope when shooting
        drawoval (xAxis + shock, yAxis + shock, 50, 50, brightred)
        drawoval (xAxis + shock, yAxis + shock, 40, 40, brightred)
        drawline (xAxis + 5 + shock2, yAxis + shock2, xAxis + 35 + shock2, yAxis + shock2, line)
        drawline (xAxis - 5 + shock2, yAxis + shock2, xAxis - 35 + shock2, yAxis + shock2, line)
        drawline (xAxis + shock2, yAxis + 5 + shock2, xAxis + shock2, yAxis + 35 + shock2, line)
        drawline (xAxis + shock2, yAxis - 5 + shock2, xAxis + shock2, yAxis - 35 + shock2, line)

        if whatdotcolour (xAxis, yAxis) = ballc and button = 1 then %determines if ball was hit
            score += 1
        end if
    end if

    if (button = 10) then %reloads ammo
        bullets += 100
        if (bullets >= ammo) then
            bullets := ammo
        end if
    end if

    if (bullets <= 0) then %out of ammo
        bullets := 0
        last := false
    end if

    if (button = 100) then %determines if right click is pressed
        last := true
        drawoval (xAxis, yAxis, 50, 50, scope)
        drawline (xAxis + 15, yAxis, xAxis + 45, yAxis, line)
        drawline (xAxis - 15, yAxis, xAxis - 45, yAxis, line)
        drawline (xAxis, yAxis + 15, xAxis, yAxis + 45, line)
        drawline (xAxis, yAxis - 15, xAxis, yAxis - 45, line)
    end if

    for i : 20 .. 120 by 20 %changes balls colour based on score
        if score = i then
            ballc -= 1
            if ballc <= 40 then
                ballc := 40
            end if
            if ballc >= 47 then
                ballc := 47
            end if
        end if
    end for

    locate (1, 1)
    put "X:", xAxis, "  Y:", yAxis, "  COLOUR:", whatdotcolour (xAxis, yAxis), "  LAST:", last, "  BULLETS:", bullets, "/", ammo, "  SCORE:", score %debug
    View.Update
end loop

Author:  Mackie [ Mon May 12, 2008 4:43 pm ]
Post subject:  RE:Face Shooter

Wow, that's actually fairly good, understandable code, a nice change from most Turing submissions. I like it.

Author:  syntax_error [ Mon May 12, 2008 4:56 pm ]
Post subject:  RE:Face Shooter

I enjoyed it, sorta like a target shooter game, maybe later on, have many faces then as it get harder fewer faces to hit

Author:  Tallguy [ Thu May 15, 2008 7:36 am ]
Post subject:  RE:Face Shooter

ha ha, cheezey and fun:)


: