
-----------------------------------
jamonathin
Thu Feb 24, 2005 9:21 am

My Copter Game
-----------------------------------
This is my version of the "helicopter game", you just hold the mose down (and let go) to dodge the missles.  This game has more pictures, but i dont have any cd-rw's or floppy's so i cant bring the game home and zip it, so thats why it's like this.  You have to use the top10reset once to make default scores/names.
 
var streamout : int
var highnumb : array 1 .. 10 of int
var highname : array 1 .. 10 of string
open : streamout, "top10", put
for i : 1 .. 10
    highnumb (i) := 0
    highname (i) := "Newb001"
    put : streamout, highname (i)
    put : streamout, highnumb (i)
end for
close : streamout

And Here's the game

import GUI
setscreen ("graphics:300;200,position:center;center,nobuttonbar,title: Created By: Jamonathin")

var font : int := Font.New ("Papyrus:10:bold")

var copter : array 1 .. 10 of int
copter (1) := Pic.FileNew ("copter.bmp")
copter (2) := Pic.FileNew ("copter2.bmp")
copter (3) := Pic.FileNew ("copter.bmp")
copter (4) := Pic.FileNew ("copter2.bmp")
copter (5) := Pic.FileNew ("copter.bmp")
copter (6) := Pic.FileNew ("copter2.bmp")
copter (7) := Pic.FileNew ("copter.bmp")
copter (8) := Pic.FileNew ("copter2.bmp")

var back : array 1 .. 10 of int
back (1) := Pic.FileNew ("clouds.bmp")
back (2) := Pic.FileNew ("clouds.bmp")
back (3) := Pic.FileNew ("clouds.bmp")
back (4) := Pic.FileNew ("clouds.bmp")

var missile : array 1 .. 8 of int
missile (1) := Pic.FileNew ("missile.bmp")
missile (2) := Pic.FileNew ("missile2.bmp")
missile (3) := Pic.FileNew ("missile.bmp")
missile (4) := Pic.FileNew ("missile2.bmp")
missile (5) := Pic.FileNew ("missile.bmp")
missile (6) := Pic.FileNew ("missile2.bmp")

var heliback : int := Pic.FileNew ("heliback.bmp")
var cldx1, cldx2, name : int := 0
var maxpeople : int := 10
var newname : string
var names : array 1 .. maxpeople of string
var scores : array 1 .. maxpeople of int
var fileName : string := "top10.txt"
var fileIn : int
var trailx, traily : array 1 .. 50 of int
var misx, misy, misalive : array 1 .. 100 of int
var x, y, z, mousex, mousey, random, count, finish, dodged, ccount, backnum, backselect, scalepic, charselect, start, miscount, player, misselect, missiles : int := 1

backnum := 1
x := 50
y := 125
cldx2 := 500
finish := 0
dodged := 0

for i : 1 .. 100
    misx (i) := 500
    misy (i) := 250
    misalive (i) := 1
end for

proc sort
    for i : 1 .. maxpeople
        for q : 2 .. maxpeople
            if scores (q - 1) < scores (q) then
                var temp : int := scores (q - 1)
                scores (q - 1) := scores (q)
                scores (q) := temp
                var temp2 : string := names (q - 1)
                names (q - 1) := names (q)
                names (q) := temp2
            end if
        end for
    end for
end sort

proc refresh
    cls
    Pic.Draw (back (backnum), cldx1, 0, picCopy)
    Pic.Draw (back (backnum), cldx2, 0, picCopy)
    Pic.Draw (copter (ccount), x, y, picMerge)
    for i : 1 .. count
        if misalive (i) = 1 then
            Pic.Draw (missile (miscount), misx (i), misy (i), picMerge)
        end if
    end for
    View.Update
end refresh

process malive
    for i : 1 .. count
        if misx (i) + 80  y and misy (i) < y + 17 and misx (i) + 80 > x then
            finish := 1
        end if
    end for
end hit

proc game
    setscreen ("graphics:500;300,position:center;center,nobuttonbar,offscreenonly,title: Created By: Jamonathin")
    colorback (black)
    cls
    loop
        color (white)
        mousewhere (mousex, mousey, z)
        if x > 95 then
            y -= 4
        end if
        if z = 1 then
            y += 8
        end if
        if x < 100 then
            x += 2
        else
            cldx1 -= 2
            cldx2 -= 2
            misx (count) -= 8 + (dodged div 5)
        end if
        if cldx1 + 500  10 then
            drawfillbox (0, 0, maxx, 50, black)
            locate (5, 14)
            get newname
        end if
        exit when length (newname) < 11
    end loop
end if
var done : int := 0
for decreasing i : 10 .. 2
    if dodged > highnumb (i) and dodged  highnumb (1) then
        for decreasing q : 10 .. 2
            highnumb (q) := highnumb (q - 1)
            highname (q) := highname (q - 1)
        end for
        highnumb (1) := dodged
        highname (1) := newname
        done := 1
    end if
end for
var streamout : int
open : streamout, "top10", put
for i : 1 .. 10
    put : streamout, highname (i)
    put : streamout, highnumb (i)
end for
close : streamout
setscreen ("graphics:300;350,position:center;center,nobuttonbar,nooffscreenonly,title: Created By: Jamonathin")
colorback (black)
color (yellow)
cls
put "         -= Top 10 Scores =-"
color (white)
for i : 1 .. 10
    locate (i + 2, 2)
    put highname (i)
    locate (i + 2, 12)
    put " - ", highnumb (i)
end for
put skip
if dodged >= highnumb (10) then
    color (10)
else
    color (12)
end if
locate (15, 2)
put "       You Dodged ", dodged, " Missiles."
put skip
put "             Speed = ", 8 + (dodged div 5)

Hope you guys like it

-----------------------------------
Drakain Zeil
Thu Feb 24, 2005 2:08 pm


-----------------------------------
You really should have made those BMPs to JPGs for bandwidth's sake, and your attachment size limit.

You can do it with most graphical programs, like the gimp (www.gimp.org)

-----------------------------------
jamonathin
Thu Feb 24, 2005 2:21 pm


-----------------------------------
Sounds hawt, ill do that next time

-----------------------------------
Tony
Thu Feb 24, 2005 2:41 pm


-----------------------------------
put it all together into a single zip file. I'm not downloading 6 images and making two turing files.

-----------------------------------
Carino
Thu Feb 24, 2005 2:46 pm


-----------------------------------
I agree. Include both turing files and all the pics in a zip, its wayyy to much to download.

-----------------------------------
Token
Thu Feb 24, 2005 4:09 pm


-----------------------------------
well i had nothing to do so i did it all and it looks pretty good, the only thing is that when you release the button it should still go up for a little bit, so that it would still have an upward motion like this
http://www.ebaumsworld.com/helicopter.shtml
other than that it seems great!

-----------------------------------
[Gandalf]
Fri Feb 25, 2005 7:00 pm


-----------------------------------
please make it a .zip file - I want to try it, but nobody wants to put all that together  :?

-----------------------------------
Flikerator
Fri Feb 25, 2005 11:50 pm


-----------------------------------
I agree. I want to try it out but im just so lazy i don't want to dowload all those.

-----------------------------------
person
Sat Feb 26, 2005 1:24 pm


-----------------------------------
zipping it is the way to go, but if ur lazy like we r, can u give us a snap shot

zipping it would be great, i really want to play it

-----------------------------------
jamonathin
Sun Feb 27, 2005 5:52 pm


-----------------------------------
Sorry it took me so long. . i've had a busy past few days, but here it is.

-----------------------------------
person
Sun Feb 27, 2005 6:17 pm


-----------------------------------
doesnt work for some reason

-----------------------------------
jamonathin
Sun Feb 27, 2005 6:47 pm


-----------------------------------
You proabibly didn't catch it, and i should have re-said it, but in my original post it says to run the top10reset frist, so you can have a default scores/names in the top10, and it's also there to reset the top10 (hence the name), so that's why it didn't work right.

-----------------------------------
ssr
Sun Feb 27, 2005 7:13 pm


-----------------------------------
ok thats a nice game
but I thought u could make the copter less complicated (the graphics) it would actually look more smoothly....
and ya also
make an option for the users to change the speed I donno, its stil too slow and easy

oooo
u knwo waht would be great
to let teh user make their own levels....

 :lol:  :lol:  :lol: 
nice game

-----------------------------------
jamonathin
Sun Feb 27, 2005 7:27 pm


-----------------------------------
well, "technically", the user can make thier own backgrounds, just find a pic and replace one of the back (2) := Pic.FileNew ("clouds.bmp")
and i'm not sure how far you made it in the game, but the speed changes for every 5 missles you dodge
 misx (count) -= 8 + (dodged div 5) 
but the graphics on the helicopter can use a lil editing, i'll look into that next time ssr  :wink: 
but thx for the tips :)

-----------------------------------
Bacchus
Sun Feb 27, 2005 7:54 pm


-----------------------------------
psst.. processes r evil :P also i agree with the other ppl that it should move upwards after ur done clicking, use velocities and gravity to do that. in example: (u kno i figured out i do most of my programing from ideas i get from ppl here on compsci lol)
setscreen ("title:Copter Thingy by Bacchus,offscreenonly,nobuttonbar,graphics:300;300,position:centre;middle")

var mx, my, mb : int
var x, y, vx, vy : real
const gravity := 0.8
var chars : array char of boolean
var done : boolean := false
var boom : flexible array 1 .. 0 of
    record
        x, y, vx, vy : real
    end record

x := 100
y := 150
vx := 0
vy := 0

colorback (2)
cls

color (4)
put "Click the Mouse to increase your upwards speed"
put "Press 'w' to add another obstical, press 'q' to take one away"

loop
    cls
    Mouse.Where (mx, my, mb)

    if mb = 1 then
        vy += 1.5
    end if

    if y < 50| y + 5 > maxy - 50 then
        done := true
    end if

    Input.KeyDown (chars)
    if chars ('w') then
        new boom, upper (boom) + 1
        boom (upper (boom)).x := maxx
        boom (upper (boom)).y := Rand.Int (0, maxy)
        boom (upper (boom)).vx := Rand.Int (5, 20)
        boom (upper (boom)).vy := Rand.Real
        if boom (upper (boom)).vy >= 0.7 then
            boom (upper (boom)).vy := 0
        end if
    elsif chars ('q') then
        if upper (boom) > 0 then
            new boom, upper (boom) - 1
        end if
    end if

    vy -= gravity
    x += vx
    y += vy

    drawfillbox (0, 0, maxx, 50, 3)
    drawfillbox (0, maxy, maxx, maxy - 50, 3)
    drawfillbox (round (x), round (y), round (x + 5), round (y + 5), 1)

    for i : 1 .. upper (boom)
        boom (i).x -= boom (i).vx
        boom (i).y -= boom (i).vy
        if boom (i).x + 40 = 0.7 then
                boom (i).vy := 0
            end if
        end if
        drawfillbox (round (boom (i).x), round (boom (i).y), round (boom (i).x + 40), round (boom (i).y + 20), 3)
        if (x >= boom (i).x & x = boom (i).x & x + 5 = boom (i).y & y = boom (i).y & y + 5 