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

Username:   Password: 
 RegisterRegister   
 Ball On Wall Glitch
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
[Flame][Boy]




PostPosted: Thu Dec 15, 2005 7:19 pm   Post subject: Ball On Wall Glitch

Ok im making a game where you have to get thru the maze as fast as you can but if you touch wall the game ends. It works if you run directly into it the game ends, but if you stop under the top wall and the wall pointing up point the ball goes over the wall and doesnt end... anyone know how to fix that??

Heres the code

code:

var ch : array char of boolean
var x : int := 12       
var y : int := 15
var col : int := 8
var score : int := 0
var x2 : int := Rand.Int (1, maxx)
var y2 : int := Rand.Int (1, maxy)
var x3 : int := Rand.Int (1, maxx)
var y3 : int := Rand.Int (1, maxy)
var x4 : int := Rand.Int (1, maxx)
var y4 : int := Rand.Int (1, maxy)
var x5 : int := Rand.Int (1, maxx)
var y5 : int := Rand.Int (1, maxy)
var x6 : int := Rand.Int (1, maxx)
var y6 : int := Rand.Int (1, maxy)
var timedelay : int := 0
colourback (black)
cls
colour (white)
var key : string (1)
put "           Welcome To The Smiley Face Ball Catching Game"
put ""
put " How long would you like the delay to be? (0..50)"

get timedelay
cls
put ""
put "           Welcome To The Smiley Face Ball Catching Game"
put " Controls : "
put " Arrow Keys = Movement"
put " O = Color Change"

setscreen ("offscreenonly")
getch (key)

loop
 
    %Maze Walls%

    Draw.ThickLine (x - 5, y - 5, x + 5, y - 5, 3, black)
    Draw.ThickLine (0, 2, 530, 2, 5, brightred)
    Draw.ThickLine (0, 30, 500, 30, 5, brightred)
    Draw.ThickLine (530, 2, 530, 50, 5, brightred)
    Draw.ThickLine (500, 30, 500, 70, 5, brightred)

    Input.KeyDown (ch)

    %Collision Detection%

    if ch (KEY_RIGHT_ARROW) and y - 2 > 0 and View.WhatDotColour (x + 11, y)= brightred then
        cls
        exit
    end if
    if ch (KEY_LEFT_ARROW) and y - 2 > 0 and View.WhatDotColour (x - 11, y) = brightred then
        cls
        exit
    end if
    if ch (KEY_DOWN_ARROW) and y - 2 > 0 and View.WhatDotColour (x, y - 11) = brightred then
        cls
        exit
    end if
    if ch (KEY_UP_ARROW) and y - 2 > 0 and View.WhatDotColour (x, y + 11) = brightred then
        cls
        exit
    end if

    %Movement%

    if ch (KEY_UP_ARROW) and y - 2 > 0 and View.WhatDotColour (x, y + 10) = black then
        y := y + 1
    end if

    if ch (KEY_DOWN_ARROW) and y - 2 > 0 and View.WhatDotColour (x, y - 11) = black then
        y := y - 1
    end if
    if ch (KEY_LEFT_ARROW) and x - 2 > 0 and View.WhatDotColour (x - 11, y) = black then
        x := x - 1
    end if
    if ch (KEY_RIGHT_ARROW) and x + 2 < maxx and View.WhatDotColour (x + 11, y) = black then
        x := x + 1
    end if
    if ch ('o') then
        col := Rand.Int (1, 200)
    end if

    %Draw Character%
   
    drawfilloval (x, y, 10, 10, col)
    drawfilloval (x - 4, y + 3, 4, 4, black)
    drawfilloval (x + 4, y + 3, 4, 4, black)

    View.Update
    delay (timedelay)
    cls
   
    %Score%
   
    put "Score : ", score

end loop
[/code]
Sponsor
Sponsor
Sponsor
sponsor
[Flame][Boy]




PostPosted: Thu Dec 15, 2005 8:17 pm   Post subject: (No subject)

Heres what i mean

[img] http://img347.imageshack.us/img347/5430/ballgame7qz.jpg [/img]
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  [ 2 Posts ]
Jump to:   


Style:  
Search: