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

Username:   Password: 
 RegisterRegister   
 Don't fall off. and yes, comment away.
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
r.m_spy




PostPosted: Sun Jun 08, 2008 7:52 am   Post subject: Don't fall off. and yes, comment away.

%controls: move your mouse onto the black square. keep it on the box, and for two player, arrow keys to move the box

setscreen("graphics:max,max")
var x,y:=maxx div 2
y:=maxy div 2
var z,c,btn,sc,l,di,du:int
var k:array char of boolean
var up:char:=chr(200)
var le:char:=chr(203)
var ri:char:=chr(205)
var d:char:=chr(208)
var ch:string
l:=3
di:=1
du:=1
loop
cls
put"enter 'start' to start game"
put"enter 'exit to exit"
put "enter 2p for two player"
get ch
cls
if ch="start" then
loop
delay(100)
cls
Mouse.Where(z,c,btn)
drawfillbox(x-100,y-100,x+100,y+100,black)
if z>x+100 or z<x-100 or c>y+100 or c<y-100 then
put"put your mouse back on to restart"
sc:=0
l:=5
end if
put"part one"
put"level: ",l div 5
put"sc: ",sc
sc:=sc+1
if x>maxx then
du:=2
elsif x<0 then
du:=1
end if
if du=2 then
x:=x-l
else
x:=x+l
end if
if y>maxy then
di:=2
elsif y<0 then
di:=1
end if
if di=2 then
y:=y-l
else
y:=y+l
end if
if sc>150 and sc<300 then
l:=10
elsif sc>300 and sc<450 then
l:=15
elsif sc>450 and sc>600 then
l:=20
end if
exit when sc>600
end loop

cls
put"part 1 passed"
delay(1000)
cls
sc:=0

loop
delay(100)
cls
Mouse.Where(z,c,btn)
drawfillbox(x-60,y-60,x+60,y+60,black)
if z>x+60 or z<x-60 or c>y+60 or c<y-60 then
put"put your mouse back on to restart"
sc:=0
l:=5
end if
put"part 2 "..
put"level: ",l div 5," "..
put"sc: ",sc,""..
sc:=sc+1
if x>maxx then
du:=2
elsif x<0 then
du:=1
end if
if du=2 then
x:=x-l
else
x:=x+l
end if
if y>maxy then
di:=2
elsif y<0 then
di:=1
end if
if di=2 then
y:=y-l
else
y:=y+l
end if
if sc>150 and sc<300 then
l:=10
elsif sc>300 and sc<450 then
l:=15
elsif sc>450 and sc>600 then
l:=20
end if
exit when sc>600
end loop

cls
put"part 2 passed"
delay(1000)
cls
sc:=0
var dw :int:=100

loop
delay(100)
cls
Mouse.Where(z,c,btn)
drawfillbox(x-dw,y-dw,x+dw,y+dw,black)
drawbox(x-dw+25,y-dw+25,x+dw-25,y+dw-25,brightred)
if z>x+dw or z<x-dw or c>y+dw or c<y-dw then
put"put your mouse back on to restart"
sc:=0
l:=5
dw:=100
end if
put"part 2 "..
put"level: ",l div 5," "..
put"sc: ",sc,""..
sc:=sc+1
if x>maxx then
du:=2
elsif x<0 then
du:=1
end if
if du=2 then
x:=x-l
else
x:=x+l
end if
if y>maxy then
di:=2
elsif y<0 then
di:=1
end if
if di=2 then
y:=y-l
else
y:=y+l
end if
if sc>150 and sc<300 then
l:=10
dw:=75
elsif sc>300 and sc<450 then
l:=15
dw:=65
elsif sc>450 and sc>600 then
dw:=40
l:=55
end if
exit when sc>600
end loop

cls
put"part 3 passed, last level"
delay(1000)
cls
sc:=0
var clr:int:=black
var p :int:=70
dw:=70
p:=0
loop
delay(100)
cls
Mouse.Where(z,c,btn)
drawfillbox(x-dw,y-dw,x+dw,y+dw,clr)
if z>x+70 or z<x-70 or c>y+70 or c<y-70 then
put"put your mouse back on to restart"
sc:=0
l:=5
clr:=black
p:=1
end if
if sc>450 then
dw:=0
if p=0 then
clr:=white
else
clr:=black
end if
end if
put"part 2 "..
put"level: ",l div 5," "..
put"sc: ",sc,""..
sc:=sc+1
if x>maxx then
du:=2
elsif x<0 then
du:=1
end if
if du=2 then
x:=x-l
else
x:=x+l
end if
if y>maxy then
di:=2
elsif y<0 then
di:=1
end if
if di=2 then
y:=y-l
else
y:=y+l
end if
if sc>150 and sc<300 then
l:=10
clr:=grey
p:=0
elsif sc>300 and sc<450 then
l:=15
clr:=brightwhite
elsif sc>450 and sc>600 then
dw:=0
end if
exit when sc>600
end loop
elsif ch="2p" then
loop
delay(100)
cls
Mouse.Where(z,c,btn)
drawfillbox(x-100,y-100,x+100,y+100,black)
if z>x+100 or z<x-100 or c>y+100 or c<y-100 then
put"put your mouse back on to restart"
sc:=0
l:=5
end if
put"part one"
put"level: ",l div 5
put"sc: ",sc
sc:=sc+1
Input.KeyDown(k)
if k(le) then
if x>0 then
x:=x-l
end if
elsif k(ri) then
if x<maxx then
x:=x+l
end if
end if
if k(d) then
if y>0 then
y:=y-l
end if
elsif k(up) then
if y<maxx then
y:=y+l
end if
end if
if sc>150 and sc<300 then
l:=10
elsif sc>300 and sc<450 then
l:=15
elsif sc>450 and sc>600 then
l:=20
end if
exit when sc>600
end loop
end if
exit when ch="exit"
end loop

%if you have any suggestions to improve, how to end without winning, ecit it.
Sponsor
Sponsor
Sponsor
sponsor
michaelp




PostPosted: Sun Jun 08, 2008 8:18 am   Post subject: RE:Don\'t fall off. and yes, comment away.

So, you want people to comment on your game?
Well, you could start by indenting properly( indenting at all actually) and putting your code in [code] tags.
You could also try adding some comments in your code so people can understand it more when they read it.
r.m_spy




PostPosted: Sun Jun 08, 2008 8:32 am   Post subject: Re: Don't fall off. and yes, comment away. happy!

code:

setscreen ("graphics:max,max")
var x, y := maxx div 2
y := maxy div 2
var z, c, btn, sc, l, di, du : int
var k : array char of boolean
var up : char := chr (200)
var le : char := chr (203)
var ri : char := chr (205)
var d : char := chr (208)
var ch : string
l := 3
di := 1
du := 1
%menu
loop
    cls
    put "enter 'start' to start game"
    put "enter 'exit to exit"
    put "enter 2p for two player"
    get ch
    cls
    if ch = "start" then
    %this is part 1
        loop
            delay (100)
            cls
            Mouse.Where (z, c, btn)
            drawfillbox (x - 100, y - 100, x + 100, y + 100, black)
            if z > x + 100 or z < x - 100 or c > y + 100 or c < y - 100 then
                put "put your mouse back on to restart"
                sc := 0
                l := 5
            end if
            put "part one"
            put "level: ", l div 5
            put "sc: ", sc
            sc := sc + 1
            if x > maxx then
                du := 2
            elsif x < 0 then
                du := 1
            end if
            if du = 2 then
                x := x - l
            else
                x := x + l
            end if
            if y > maxy then
                di := 2
            elsif y < 0 then
                di := 1
            end if
            if di = 2 then
                y := y - l
            else
                y := y + l
            end if
            if sc > 150 and sc < 300 then
                l := 10
            elsif sc > 300 and sc < 450 then
                l := 15
            elsif sc > 450 and sc > 600 then
                l := 20
            end if
            exit when sc > 600
        end loop

        cls
        put "part 1 passed"
        delay (1000)
        cls
        sc := 0
%part 2
        loop
            delay (100)
            cls
            Mouse.Where (z, c, btn)
            drawfillbox (x - 60, y - 60, x + 60, y + 60, black)
            if z > x + 60 or z < x - 60 or c > y + 60 or c < y - 60 then
                put "put your mouse back on to restart"
                sc := 0
                l := 5
            end if
            put "part 2     " ..
            put "level: ", l div 5, "     " ..
            put "sc: ", sc, "" ..
            sc := sc + 1
            if x > maxx then
                du := 2
            elsif x < 0 then
                du := 1
            end if
            if du = 2 then
                x := x - l
            else
                x := x + l
            end if
            if y > maxy then
                di := 2
            elsif y < 0 then
                di := 1
            end if
            if di = 2 then
                y := y - l
            else
                y := y + l
            end if
            if sc > 150 and sc < 300 then
                l := 10
            elsif sc > 300 and sc < 450 then
                l := 15
            elsif sc > 450 and sc > 600 then
                l := 20
            end if
            exit when sc > 600
        end loop

        cls
        put "part 2 passed"
        delay (1000)
        cls
        sc := 0
        var dw : int := 100
%part 3
        loop
            delay (100)
            cls
            Mouse.Where (z, c, btn)
            drawfillbox (x - dw, y - dw, x + dw, y + dw, black)
            drawbox (x - dw + 25, y - dw + 25, x + dw - 25, y + dw - 25, brightred)
            if z > x + dw or z < x - dw or c > y + dw or c < y - dw then
                put "put your mouse back on to restart"
                sc := 0
                l := 5
                dw := 100
            end if
            put "part 2     " ..
            put "level: ", l div 5, "     " ..
            put "sc: ", sc, "" ..
            sc := sc + 1
            if x > maxx then
                du := 2
            elsif x < 0 then
                du := 1
            end if
            if du = 2 then
                x := x - l
            else
                x := x + l
            end if
            if y > maxy then
                di := 2
            elsif y < 0 then
                di := 1
            end if
            if di = 2 then
                y := y - l
            else
                y := y + l
            end if
            if sc > 150 and sc < 300 then
                l := 10
                dw := 75
            elsif sc > 300 and sc < 450 then
                l := 15
                dw := 65
            elsif sc > 450 and sc > 600 then
                dw := 40
                l := 55
            end if
            exit when sc > 600
        end loop

        cls
        put "part 3 passed, last level"
        delay (1000)
        cls
        sc := 0
        var clr : int := black
        var p : int := 70
        dw := 70
        p := 0
        %part 4
        loop
            delay (100)
            cls
            Mouse.Where (z, c, btn)
            drawfillbox (x - dw, y - dw, x + dw, y + dw, clr)
            if z > x + 70 or z < x - 70 or c > y + 70 or c < y - 70 then
                put "put your mouse back on to restart"
                sc := 0
                l := 5
                clr := black
                p := 1
            end if
            if sc > 450 then
                dw := 0
                if p = 0 then
                    clr := white
                else
                    clr := black
                end if
            end if
            put "part 2     " ..
            put "level: ", l div 5, "     " ..
            put "sc: ", sc, "" ..
            sc := sc + 1
            if x > maxx then
                du := 2
            elsif x < 0 then
                du := 1
            end if
            if du = 2 then
                x := x - l
            else
                x := x + l
            end if
            if y > maxy then
                di := 2
            elsif y < 0 then
                di := 1
            end if
            if di = 2 then
                y := y - l
            else
                y := y + l
            end if
            if sc > 150 and sc < 300 then
                l := 10
                clr := grey
                p := 0
            elsif sc > 300 and sc < 450 then
                l := 15
                clr := brightwhite
            elsif sc > 450 and sc > 600 then
                dw := 0
            end if
            exit when sc > 600
        end loop
    elsif ch = "2p" then
    %2player
        loop
            delay (100)
            cls
            Mouse.Where (z, c, btn)
            drawfillbox (x - 100, y - 100, x + 100, y + 100, black)
            if z > x + 100 or z < x - 100 or c > y + 100 or c < y - 100 then
                put "put your mouse back on to restart"
                sc := 0
                l := 5
            end if
            put "part one"
            put "level: ", l div 5
            put "sc: ", sc
            sc := sc + 1
            Input.KeyDown (k)
            if k (le) then
                if x > 0 then
                    x := x - l
                end if
            elsif k (ri) then
                if x < maxx then
                    x := x + l
                end if
            end if
            if k (d) then
                if y > 0 then
                    y := y - l
                end if
            elsif k (up) then
                if y < maxx then
                    y := y + l
                end if
            end if
            if sc > 150 and sc < 300 then
                l := 10
            elsif sc > 300 and sc < 450 then
                l := 15
            elsif sc > 450 and sc > 600 then
                l := 20
            end if
            exit when sc > 600
        end loop
    end if
    exit when ch = "exit"
end loop
Insectoid




PostPosted: Mon Jun 09, 2008 11:34 am   Post subject: RE:Don\'t fall off. and yes, comment away.

1. View.Update
2. Not bad!
Sean




PostPosted: Mon Jun 09, 2008 12:15 pm   Post subject: Re: Don't fall off. and yes, comment away.

Turing:

View.Set ("offscreenonly")


Then use View.Update in your program to stop the flickering.

Turing:

var x, y := maxx div 2
y := maxy div 2


Here you are declaring x and y as maxx div 2, but then re-declaring y. Just declare y once as you want, meaning you will have to declare each seperatly.
Aziz




PostPosted: Mon Jun 09, 2008 1:41 pm   Post subject: RE:Don\'t fall off. and yes, comment away.

BTW, View.Set is only declared once (at the top of the file, after imports and before var declarations usually). See help file for more info.

And what Sean means is instead of

code:
var x, y := maxx div 2
y := maxy div 2


use the following:

code:
var x := maxx div 2
var y := maxy div 2


"var x, y := maxx div 2" sets BOTH values, which is one more operation than neccesary.
jeffgreco13




PostPosted: Mon Jun 09, 2008 1:44 pm   Post subject: Re: Don't fall off. and yes, comment away.

nice program tho i like the idea. get rid of the flicker and you should have a decent game. was this an FP for school? or just a hobby.

Aziz can't help but notice you don't have very many bits eh? lol
Aziz




PostPosted: Mon Jun 09, 2008 2:49 pm   Post subject: RE:Don\'t fall off. and yes, comment away.

I'm trying to compensate.
Sponsor
Sponsor
Sponsor
sponsor
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 1  [ 8 Posts ]
Jump to:   


Style:  
Search: