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

Username:   Password: 
 RegisterRegister   
 Help With This Game Please !!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Sam




PostPosted: Wed Dec 12, 2007 4:13 pm   Post subject: Help With This Game Please !!!

so i am creating a game for my school . so this is my game basically whats point of the game is the pacman eating the red circles and everytime he eats one he get 1 point but now i need to figure out a way to put a Black Circle which if the pacman eats the game will be over .. pleaseee help me guyss

Here is my Code

Turing:

var pausekey : char
locate (1, 30)
put " Controls: Arrows Keys To Move "
put "  Blue= +1 , Brightred= Game Over "
put " Press Any key to Continue"
View.Set ("graphics")
pausekey := getchar
cls

var x, y : int := 200
var input : string (1)
var dir : string := "right"

var timer : int := 0
var x_o, y_o : int := 0

var eaten : boolean := false
var score : int := 0
var speed : int := 500
loop
    locate (1, 35)
    put "Score: ", score

    drawfillarc (x, y, 30, 30, 0, 340, blue)
    drawfilloval (x + 10, y + 15, 5, 5, white)

    delay (5)
    drawfillarc (x, y, 30, 30, 0, 340, white)
    drawfilloval (x + 10, y + 15, 5, 5, white)

    if timer mod speed = 0 then
        eaten := false
        drawfilloval (x_o, y_o, 20, 20, white)
        x_o := Rand.Int (20, maxx - 20)
        y_o := Rand.Int (20, maxy - 20)
    end if

    if not eaten then
        drawfilloval (x_o, y_o, 20, 20, brightred)
    end if

    if hasch () then
        getch (input)
        if input = KEY_RIGHT_ARROW then
            dir := "right"
        elsif input = KEY_LEFT_ARROW then
            dir := "left"
        elsif input = KEY_UP_ARROW then
            dir := "up"
        elsif input = KEY_DOWN_ARROW then
            dir := "down"
        end if
    end if
    case dir of
        label "left" :
            x := x - 1
        label "right" :
            x := x + 1
        label "up" :
            y := y + 1
        label "down" :
            y := y - 1
    end case
    if x = maxx then
        x := 0
    elsif x = 0 then
        x := maxx
    elsif y = 0 then
        y := maxy
    elsif y = maxy then
        y := 0
    end if
    if x = 0 then
        dir := "right"
    elsif x = maxx then
        dir := "left"

    end if

    if abs (x - x_o) < 20 and abs (y - y_o) < 20 and eaten = false then
        eaten := true
        score := score + 1
        drawfilloval (x_o, y_o, 20, 20, white)
        speed := speed - 50
    end if

    timer := timer + 1
end loop
Sponsor
Sponsor
Sponsor
sponsor
StealthArcher




PostPosted: Wed Dec 12, 2007 4:22 pm   Post subject: Re: Help With This Game Please !!!

Turing:
var pausekey : char
locate (1, 30)
put " Controls: Arrows Keys To Move "
put " Blue= +1 , Brightred= Game Over "
put " Press Any key to Continue"
View.Set ("graphics")
pausekey := getchar
cls

var x, y : int := 200
var input : string (1)
var dir : string := "right"

var timer : int := 0
var x_o, y_o : int := 0

var eaten : boolean := false
var score : int := 0
var speed : int := 500
loop
locate (1, 35)
put "Score: ", score

drawfillarc (x, y, 30, 30, 0, 340, blue)
drawfilloval (x + 10, y + 15, 5, 5, white)

delay (5)
drawfillarc (x, y, 30, 30, 0, 340, white)
drawfilloval (x + 10, y + 15, 5, 5, white)

if timer mod speed = 0 then
eaten := false
drawfilloval (x_o, y_o, 20, 20, white)
x_o := Rand.Int (20, maxx - 20)
y_o := Rand.Int (20, maxy - 20)
end if

if not eaten then
drawfilloval (x_o, y_o, 20, 20, brightred)
end if

if hasch () then
getch (input)
if input = KEY_RIGHT_ARROW then
dir := "right"
elsif input = KEY_LEFT_ARROW then
dir := "left"
elsif input = KEY_UP_ARROW then
dir := "up"
elsif input = KEY_DOWN_ARROW then
dir := "down"
end if
end if
case dir of
label "left" :
x := x - 1
label "right" :
x := x + 1
label "up" :
y := y + 1
label "down" :
y := y - 1
end case
if x = maxx then
x := 0
elsif x = 0 then
x := maxx
elsif y = 0 then
y := maxy
elsif y = maxy then
y := 0
end if
if x = 0 then
dir := "right"
elsif x = maxx then
dir := "left"

end if

if abs (x - x_o) < 20 and abs (y - y_o) < 20 and eaten = false then
eaten := true
score := score + 1
drawfilloval (x_o, y_o, 20, 20, white)
speed := speed - 50
end if

timer := timer + 1
end loop


Doing that makes it much nicer to look at, and would've kept your indentation, press more tags when posting, select syntax, then type turing in the quotes in the tag.
Sam




PostPosted: Wed Dec 12, 2007 4:35 pm   Post subject: RE:Help With This Game Please !!!

ok thanks for the advice but can u please help me with the game ..
HeavenAgain




PostPosted: Wed Dec 12, 2007 8:14 pm   Post subject: RE:Help With This Game Please !!!

just like how you did with red, nice game btw Very Happy
but instead of score add 1, you exit the loop and say game over? so bascailly just add another drawoval method and draw it blue, and check collsion for that blue one

btw adding View.Set("offscreen") at the top of your code
and View.Update after whenever you have cls, will make the game look nicer Wink
good luck
Sam




PostPosted: Wed Dec 12, 2007 8:54 pm   Post subject: RE:Help With This Game Please !!!

Thank you this is my first time doing something like this btw i dont get it where do i put the code little help please i would apriciate it if you tell me where to put that in the code or do it for me thank you Smile
Nick




PostPosted: Thu Dec 13, 2007 6:18 am   Post subject: RE:Help With This Game Please !!!

heres an example of exiting the program
code:
if condition met then
exit %or if in a procedure to quit then...
return %not both are nescasary


also the View.Update should be at the bottom of drawing everything where the cls (preffabarly to me at the top Razz) for most people go directly after View.Update

as for the View.Set("offscreenonly") it is in the program once and can be written anywhere before the program has outputted anything to the run window (so before a circle is drawn or text has been written for example) however most people (including me) place it at the very top
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  [ 6 Posts ]
Jump to:   


Style:  
Search: