Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My Copter Game
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jamonathin




PostPosted: Thu Feb 24, 2005 9:21 am   Post subject: 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.
[ Top10reset ]
code:

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
code:

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 <= 0 then
            misalive (i) := 0
            misx (i) := 1000
            count += 1
            dodged += 1
            randint (random, 20, 260)
            misy (count) := random
        end if
    end for
end malive

process hit
    for i : 1 .. 100
        if misx (i) < x + 77 and misy (i) > 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 <= 0 then
            cldx1 := 500
        elsif cldx2 + 500 <= 0 then
            cldx2 := 500
        end if
        if y + 30 >= maxy or y <= 0 then
            finish := 1
        end if
        fork malive
        fork hit
        miscount := missiles
        ccount := player
        refresh
        delay (5)
        miscount := missiles + 1
        ccount := player + 1
        refresh
        delay (5)
        exit when finish = 1
    end loop
end game

proc slider (value : int)
    scalepic := Pic.Scale (back (value), 150, 100)
    Pic.Draw (scalepic, 25, 120, picCopy)
    backnum := value
end slider

proc charslider (thing : int)
    player := (thing * 2) - 1
    drawfillbox (240, 200, 317, 229, red)
    Pic.Draw (copter (player), 240, 200, picMerge)
end charslider

proc misslider (thinger : int)
    missiles := (thinger * 2) - 1
    drawfillbox (240, 120, 357, 160, red)
    Pic.Draw (missile (missiles), 240, 120, picMerge)
end misslider

Pic.Draw (heliback, 0, 0, picMerge)
Font.Draw ("Welcome to Dodger 2.0", 2, 155, font, red)
Font.Draw ("**Press Any Key to Start**", 52, 15, font, yellow)

loop
    mousewhere (mousex, mousey, z)
    exit when hasch or z = 1
end loop

setscreen ("graphics:400;300,position:center;center,nobuttonbar")
colorback (red)
cls

Font.Draw ("Options Menu", 145, 270, font, yellow)
backselect := GUI.CreateHorizontalSlider (40, 100, 120, 1, 4, 1, slider)
charselect := GUI.CreateHorizontalSlider (240, 175, 80, 1, 4, 1, charslider)
misselect := GUI.CreateHorizontalSlider (240, 100, 80, 1, 3, 1, misslider)
scalepic := Pic.Scale (back (1), 150, 100)
Pic.Draw (scalepic, 25, 120, picCopy)
Pic.Draw (copter (1), 240, 200, picMerge)
Pic.Draw (missile (miscount), 240, 120, picMerge)
start := GUI.CreateButton (175, 25, 50, "Start", game)

loop
    exit when GUI.ProcessEvent or finish = 1
end loop

delay (500)
cls
% Getting the previous Top 10 Scores
var streamin : int
var highnumb : array 1 .. 10 of int
var highname : array 1 .. 10 of string

open : streamin, "top10", get
for i : 1 .. 10
    get : streamin, highname (i)
    get : streamin, highnumb (i)
end for
close : streamin
% Checking if new score belongs on Top 10
color (white)
if dodged > highnumb (10) then
    setscreen ("graphics:300;100,position:center;center,nobuttonbar,nooffscreenonly,title:Jamonathin")
    colorback (black)
    color (yellow)
    cls
    put "          -= High Score =-"
    put ""
    put "  Enter Your Name [10 or less chars]"
    locate (5, 14)
    color (white)
    get newname
    loop
        if length (newname) > 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 (i - 1) and done = 0 then
        for decreasing q : 9 .. i
            highnumb (q + 1) := highnumb (q)
            highname (q + 1) := highname (q)
        end for
        highnumb (i) := dodged
        highname (i) := newname
        done := 1
    elsif 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
Sponsor
Sponsor
Sponsor
sponsor
Drakain Zeil




PostPosted: Thu Feb 24, 2005 2:08 pm   Post subject: (No subject)

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




PostPosted: Thu Feb 24, 2005 2:21 pm   Post subject: (No subject)

Sounds hawt, ill do that next time
Tony




PostPosted: Thu Feb 24, 2005 2:41 pm   Post subject: (No subject)

put it all together into a single zip file. I'm not downloading 6 images and making two turing files.
Carino




PostPosted: Thu Feb 24, 2005 2:46 pm   Post subject: (No subject)

I agree. Include both turing files and all the pics in a zip, its wayyy to much to download.
Token




PostPosted: Thu Feb 24, 2005 4:09 pm   Post subject: (No subject)

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]




PostPosted: Fri Feb 25, 2005 7:00 pm   Post subject: (No subject)

please make it a .zip file - I want to try it, but nobody wants to put all that together Confused
Flikerator




PostPosted: Fri Feb 25, 2005 11:50 pm   Post subject: (No subject)

I agree. I want to try it out but im just so lazy i don't want to dowload all those.
Sponsor
Sponsor
Sponsor
sponsor
person




PostPosted: Sat Feb 26, 2005 1:24 pm   Post subject: (No subject)

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




PostPosted: Sun Feb 27, 2005 5:52 pm   Post subject: (No subject)

Sorry it took me so long. . i've had a busy past few days, but here it is.
person




PostPosted: Sun Feb 27, 2005 6:17 pm   Post subject: (No subject)

doesnt work for some reason
jamonathin




PostPosted: Sun Feb 27, 2005 6:47 pm   Post subject: (No subject)

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




PostPosted: Sun Feb 27, 2005 7:13 pm   Post subject: (No subject)

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....

Laughing Laughing Laughing
nice game
jamonathin




PostPosted: Sun Feb 27, 2005 7:27 pm   Post subject: (No subject)

well, "technically", the user can make thier own backgrounds, just find a pic and replace one of the
code:
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
code:
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 Smile
Bacchus




PostPosted: Sun Feb 27, 2005 7:54 pm   Post subject: (No subject)

psst.. processes r evil Razz 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)
code:
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 then
            boom (i).x := maxx
            boom (i).y := Rand.Int (0, maxy)
            boom (i).vx := Rand.Int (5, 20)
            boom (i).vy := Rand.Real
            if boom (i).vy >= 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 + 40)| (x + 5 >= boom (i).x & x + 5 <= boom (i).x + 40) then
            if (y >= boom (i).y & y <= boom (i).y + 20)| (y + 5 >= boom (i).y & y + 5 <= boom (i).y + 20) then
                done := true
                exit
            end if
        end if
    end for

    if done then
        exit
    end if

    View.Update
    delay (80)
end loop
cls
locatexy (round (maxx / 2) - 30, round (maxy / 2))
color (4)
put "You Lose"
locatexy (round (maxx / 2) - 100, round (maxy / 2) - 50)
color (4)
put "You lasted for: ", round (Time.Elapsed / 100) / 10, " seconds"
View.Update
to lazy to make it fancy
*EDIT* forgot to indent Razz
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: