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

Username:   Password: 
 RegisterRegister   
 help with a snake game plz :P
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Naraku




PostPosted: Thu Jun 08, 2006 7:26 am   Post subject: help with a snake game plz :P

can anyone help me with the intercors Razz with fruit plz Razz
sry for any spelling errors Razz
heres my code: btw plz don't laugh Razz
code:
%unknown :P
%29/5/2006
%Summative 2
%to play a game
var snakex, snakey : int := 100
var fruit1, fruit2 : int
var count := 0
var direction : string := "null"
var snakey1, snakex1, snakey2, snakex2 : int
var chars : array char of boolean
var a, b, c, d : int
var iWindow : int

unchecked
    setscreen ("offscreenonly")
%make the snake grow, make the dot go back, make it run :P

proc fruit
    randint (fruit1, 30, 620)
    randint (fruit2, 30, 370)
end fruit

proc process1
    fruit

end process1

proc snake5
    snakey1 := snakey + 18
    snakex1 := snakex - 18
    snakex2 := snakex + 18
    snakey2 := snakey - 18
end snake5

proc snake
    drawfilloval (fruit1, fruit2, 5, 5, red)
    drawfilloval (snakex, snakey, 10, 10, black)
end snake

proc snakee
    drawfilloval (fruit1, fruit2, 5, 5, red)
    drawfilloval (snakex, snakey, 10, 10, black)
end snakee

proc lvl2
    process1
    loop
        cls
        snake5
        snakee
        locate (1, 2)

        put fruit1, " ", fruit2, "" ..
        Input.KeyDown (chars)

        if chars (KEY_UP_ARROW) then

            View.Update
            delay (10)
            cls
            direction := "up"
            locate (2, 1)


        elsif chars (KEY_RIGHT_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "right"
            locate (2, 1)


        elsif chars (KEY_LEFT_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "left"
            locate (2, 1)


        elsif chars (KEY_DOWN_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "down"

        elsif snakex >= fruit1 + 7 and snakex <= fruit1 + 7 and snakey >= fruit2 + 7 and snakey <= fruit2 + 7 then

            cls
            lvl2

        elsif snakex >= 11 and snakey <= 10 or snakex <= 627 and snakey >= 389 or snakex = 627 and snakey >= 1 or snakex = 14 and snakey >= 1 then

            snakex := 20
            snakey := 20
            count += 1

        end if
        if direction = "up" then
            View.Update
            snakey += 1
            snakey2 -= 1
            drawfilloval (snakex, snakey, 10, 10, black)
            drawfilloval (snakex, snakey2, 5, 5, black)
        elsif direction = "right" then
            View.Update
            snakex += 1
            snakex1 -= 1
            drawfilloval (snakex, snakey, 10, 10, black)
            drawfilloval (snakex1, snakey, 5, 5, black)
        elsif direction = "left" then
            View.Update
            snakex -= 1
            snakex2 -= 1
            drawfilloval (snakex, snakey, 10, 10, black)
            drawfilloval (snakex2, snakey, 5, 5, black)
        elsif direction = "down" then
            View.Update
            snakey -= 1
            snakey1 -= 1
            drawfilloval (snakex, snakey, 10, 10, black)
            drawfilloval (snakex, snakey1, 5, 5, black)
        end if
        View.Update
        delay (6)
    end loop
end lvl2

proc lvl1
    process1
    loop
        View.Update
        snake
        %:P
        put fruit1, " ", fruit2, "" ..
        Input.KeyDown (chars)
        locate (3, 1)
        View.Update
        if chars (KEY_UP_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "up"

        elsif chars (KEY_RIGHT_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "right"


        elsif chars (KEY_LEFT_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "left"


        elsif chars (KEY_DOWN_ARROW) then
            View.Update
            delay (10)
            cls
            direction := "down"

        elsif snakex >= fruit1 + 7 and snakex <= fruit1 + 7 and snakey >= fruit2 + 7 and snakey <= fruit2 + 7 then
            View.Update
            cls
            lvl2

        elsif snakex >= 11 and snakey <= 10 or snakex <= 627 and snakey >= 389 or snakex = 627 and snakey >= 1 or snakex = 14 and snakey >= 1 then

            snakex := 290
            snakey := 200

            count += 1

        elsif direction = "up" then
            View.Update
            snakey += 1
           
            drawfilloval (snakex, snakey, 10, 10, black)
           
        elsif direction = "right" then
            View.Update
            snakex += 1
           
            drawfilloval (snakex, snakey, 10, 10, black)
           
        elsif direction = "left" then
            View.Update
            snakex -= 1
           
            drawfilloval (snakex, snakey, 10, 10, black)
           
        elsif direction = "down" then
            View.Update
            snakey -= 1
           
            drawfilloval (snakex, snakey, 10, 10, black)
           
        end if
        if count >= 3 then
        View.Update
            cls
            count := 0
            put "You died please try again"

        end if
        exit when count = 3
        View.Update
        delay (6)
        cls

    end loop
end lvl1

proc intro
    loop
        Mouse.ButtonChoose ("multibutton")
        var x, y, button, left, middle, right : int
        Mouse.Where (x, y, button)
        Pic.ScreenLoad ("play.BMP", 250, 200, picCopy)
        left := button mod 10 % left = 0 or 1
        middle := (button - left) mod 100   % middle = 0 or 10
        right := button - middle - left     % right = 0 or 100
        if left = 1 and x >= 260 and x <= 335 and y >= 210 and y <= 335 then
            lvl1
        elsif right = 100 then
            cls
            put "hey it's my program and grapics :P"
        end if
        %210 = x = 235
        %210 = y = 330
        View.Update
    end loop
end intro
if count = 0 then
    intro
end if
Window.Close (iWindow)
Sponsor
Sponsor
Sponsor
sponsor
Mr. T




PostPosted: Thu Jun 08, 2006 1:56 pm   Post subject: Re: help with a snake game plz :P

Naraku wrote:
can anyone help me with the intercors Razz

Do I really want to know? Confused
Naraku




PostPosted: Thu Jun 08, 2006 4:40 pm   Post subject: Re: help with a snake game plz :P

Mr. T wrote:
Naraku wrote:
can anyone help me with the intercors Razz

Do I really want to know? Confused

lol not that kind Razz
i mean...collision Razz
Naraku




PostPosted: Fri Jun 09, 2006 12:01 pm   Post subject: (No subject)

yea... because i can't find any edit buttons i will do this Razz
anyway i worked out the collision thing now i need the tail it's not realy good Razz if u know what i mean Razz plz help ASAP tnx
i will just put the file Razz



Summative 2.t
 Description:
:P:P my snake thing :P:P

Download
 Filename:  Summative 2.t
 Filesize:  6.65 KB
 Downloaded:  80 Time(s)

Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: