
-----------------------------------
Poutine King
Tue Apr 27, 2004 8:34 am

What dot colour question, or problem more like
-----------------------------------
I am making a game similar to Pacman, I used whatdotcolor for the walls in the game.  I tried first all red and made the controls assign a variable to determine which direction the character came to repulse him in the other direction.  Then I saw that my character was passing through the corn of the walls.  So I figured that it was because it all depended on the variable that was assigned by the keys.  So I made sides to each wall in order to repulse my character yet I can still pass through the corners.  I need help. :cry: 

Heres the program (NOTE:  the circle is actually a bitmap image, but so you can run it I made it a circle)



% Muncher Game

%First page
drawfillbox (0, 0, maxx, maxy, black)

var font1, font2, font3 : int
font1 := Font.New ("binerd:60:bold")
font2 := Font.New (":15:bold")
font3 := Font.New ("timesnewroman:10:bold")

Font.Draw ("Munching", 150, 340, font1, blue)

Font.Draw ("Controls", 280, 300, font2, white)
Font.Draw ("Arrows", 298, 285, font3, white)

Font.Draw ("Rules", 290, 250, font2, white)
Font.Draw ("Avoid the monsters and munch on as much as you can.", 180, 238, font3, white)


Font.Draw ("Start Munching", 250, 100, font2, 12)
Font.Draw ("Quit Game", 265, 50, font2, 12)

delay (2000)

%Main Game starts
var chars : array char of boolean %variable for controls
%variables

var points : int %score of you the player
var mx, my : int %muncher's positions
var xb, yb : int %boundry variables
var mdirectionx, mdirectiony := 0 %variable of the direction which muncher hits a boundry
var mx2, my2 := 0 %munchers position when he hits a wall

mx := 0
my := 0
xb := 0
yb := 0

loop
    %backround
    drawfillbox (0, 0, maxx, maxy, black)


    %controls for muncher
    Input.KeyDown (chars)
    drawfilloval (mx, my, 8, 8, green)
    locate (1, 1)
    if chars (KEY_UP_ARROW) then
        my := my + 5
        mdirectiony := 1
    end if
    if chars (KEY_RIGHT_ARROW) then
        mx := mx + 5
        mdirectionx := 1
    end if
    if chars (KEY_LEFT_ARROW) then
        mx := mx - 5
        mdirectionx := 2
    end if
    if chars (KEY_DOWN_ARROW) then
        my := my - 5
        mdirectiony := 2
    end if

    %boundry
    drawbox (xb - 10, yb - 10, xb + 635, yb + 395, red)

    %boundries stop muncher
    if my = 380 then
        my := 375
    end if
    if my = -10 then
        my := -5
    end if

    if mx = 630 then
        mx := 625
    end if

    if mx = -10 then
        mx := -5
    end if


    % walls of maze (blue = top, red = bottom, yellow = left, purple = right)
    %red walls
    drawfillbox (xb + 40, yb + 40, xb + 300, yb + 60, 12) %bottom left wall corner along x
    drawfillbox (xb + 30, yb + 40, xb + 50, yb + 180, 12) % bottom left wall corner along y
    drawfillbox (xb + 30, yb + 230, xb + 50, yb + 360, 12) % top left wall corner along y
    drawfillbox (xb + 30, yb + 350, xb + 300, yb + 370, 12) % top left wall corner along x
    drawfillbox (xb + 340, yb + 350, xb + 600, yb + 370, 12) % top right wall corner along x
    drawfillbox (xb + 590, yb + 370, xb + 610, yb + 230, 12) % top right wall corner along y
    drawfillbox (xb + 590, yb + 190, xb + 610, yb + 40, 12) % bottom right wall corner along y
    drawfillbox (xb + 350, yb + 40, xb + 600, yb + 60, 12) % bottom right wall corner along x
    drawfillbox (xb + 300, yb + 180, xb + 310, yb + 200, 12) % inner monster spawn bottom left corner along the y
    drawfillbox (xb + 280, yb + 200, xb + 310, yb + 210, 12) % inner monster spawn bottom left corner along the x
    drawfillbox (xb + 300, yb + 230, xb + 310, yb + 260, 12) % inner monster spawn top left corner along the y
    drawfillbox (xb + 280, yb + 230, xb + 310, yb + 240, 12) % inner monster spawn top left corner along the x
    drawfillbox (xb + 330, yb + 230, xb + 340, yb + 260, 12) % inner monster spawn top right corner along the y
    drawfillbox (xb + 330, yb + 230, xb + 360, yb + 240, 12) % inner monster spawn top right corner along the x
    drawfillbox (xb + 330, yb + 180, xb + 340, yb + 210, 12) % inner monster spawn bottom right corner along the y
    drawfillbox (xb + 330, yb + 200, xb + 360, yb + 210, 12) % inner monster spawn bottom right corner along the x
    drawfillbox (xb + 330, yb + 230, xb + 340, yb + 260, 12) % inner monster spawn top right corner along the y
    drawfillbox (xb + 90, yb + 150, xb + 100, yb + 250, 12) % inner left entrance
    drawfillbox (xb + 550, yb + 150, xb + 560, yb + 250, 12) % inner right entrance
    drawfillbox (xb + 280, yb + 90, xb + 380, yb + 100, 12) % inner bottom entrance
    drawfillbox (xb + 270, yb + 300, xb + 380, yb + 310, 12) % inner top entrance
    drawfillbox (xb + 80, yb + 100, xb + 150, yb + 110, 12) % inner left small wall along x
    drawfillbox (xb + 80, yb + 50, xb + 90, yb + 100, 12) % inner left bottom wall along y
    drawfillbox (xb + 50, yb + 300, xb + 150, yb + 310, 12) % inner top far left corner along the x
    drawfillbox (xb + 180, yb + 300, xb + 240, yb + 310, 12) % inner top left corner along x
    drawfillbox (xb + 210, yb + 100, xb + 220, yb + 360, 12) % inner left side along y very long line
    drawfillbox (xb + 400, yb + 220, xb + 550, yb + 230, 12) % inner right side middle  along x
    drawfillbox (xb + 400, yb + 220, xb + 410, yb + 150, 12) % inner rgit middle side along y
    drawfillbox (xb + 100, yb + 200, xb + 180, yb + 210, 12) % inner top bottom left middle along x
    drawfillbox (xb + 500, yb + 360, xb + 510, yb + 280, 12) % inner top roght corner along y
    drawfillbox (xb + 450, yb + 320, xb + 460, yb + 230, 12) % inner top right corner along y

    %blue walls
    drawfillbox (xb + 40, yb + 40, xb + 300, yb + 41, blue) %bottom left wall corner along x
    drawfillbox (xb + 30, yb + 40, xb + 50, yb + 41, blue) % bottom left wall corner along y
    drawfillbox (xb + 30, yb + 230, xb + 50, yb + 231, blue) % top left wall corner along y
    drawfillbox (xb + 30, yb + 350, xb + 300, yb + 355, blue) % top left wall corner along x
    drawfillbox (xb + 30, yb + 369, xb + 300, yb + 370, blue) % top top left wall corner along x
    drawfillbox (xb + 340, yb + 350, xb + 600, yb + 351, blue) % top right wall corner along x
    drawfillbox (xb + 590, yb + 370, xb + 610, yb + 369, blue) % top right wall corner along y
    drawfillbox (xb + 590, yb + 190, xb + 610, yb + 189, blue) % bottom right wall corner along y
    drawfillbox (xb + 350, yb + 40, xb + 600, yb + 41, blue) % bottom right wall corner along x
    drawfillbox (xb + 300, yb + 180, xb + 310, yb + 181, blue) % inner monster spawn bottom left corner along the y
    drawfillbox (xb + 280, yb + 200, xb + 310, yb + 201, blue) % inner monster spawn bottom left corner along the x
    drawfillbox (xb + 300, yb + 230, xb + 310, yb + 231, blue) % inner monster spawn top left corner along the y
    drawfillbox (xb + 280, yb + 230, xb + 310, yb + 231, blue) % inner monster spawn top left corner along the x
    drawfillbox (xb + 330, yb + 230, xb + 340, yb + 231, blue) % inner monster spawn top right corner along the y
    drawfillbox (xb + 330, yb + 230, xb + 360, yb + 231, blue) % inner monster spawn top right corner along the x
    drawfillbox (xb + 330, yb + 180, xb + 340, yb + 181, blue) % inner monster spawn bottom right corner along the y
    drawfillbox (xb + 330, yb + 200, xb + 360, yb + 201, blue) % inner monster spawn bottom right corner along the x
    drawfillbox (xb + 330, yb + 230, xb + 340, yb + 231, blue) % inner monster spawn top right corner along the y
    drawfillbox (xb + 90, yb + 150, xb + 100, yb + 151, blue) % inner left entrance
    drawfillbox (xb + 550, yb + 150, xb + 560, yb + 151, blue) % inner right entrance
    drawfillbox (xb + 280, yb + 90, xb + 380, yb + 91, blue) % inner bottom entrance
    drawfillbox (xb + 270, yb + 300, xb + 380, yb + 301, blue) % inner top entrance
    drawfillbox (xb + 80, yb + 100, xb + 150, yb + 101, blue) % inner left small wall along x
    drawfillbox (xb + 80, yb + 50, xb + 90, yb + 51, blue) % inner left bottom wall along y
    drawfillbox (xb + 50, yb + 300, xb + 150, yb + 301, blue) % inner top far left corner along the x
    drawfillbox (xb + 180, yb + 300, xb + 240, yb + 301, blue) % inner top left corner along x
    drawfillbox (xb + 210, yb + 100, xb + 220, yb + 101, blue) % inner left side along y very long line
    drawfillbox (xb + 400, yb + 220, xb + 550, yb + 221, blue) % inner right side middle  along x
    drawfillbox (xb + 400, yb + 220, xb + 410, yb + 219, blue) % inner rgit middle side along y
    drawfillbox (xb + 100, yb + 200, xb + 180, yb + 201, blue) % inner top bottom left middle along x
    drawfillbox (xb + 500, yb + 360, xb + 510, yb + 359, blue) % inner top roght corner along y
    drawfillbox (xb + 450, yb + 320, xb + 460, yb + 221, blue) % inner top right corner along y

    %purple walls
    drawfillbox (xb + 30, yb + 40, xb + 31, yb + 180, purple) % bottom left wall corner along y
    drawfillbox (xb + 30, yb + 230, xb + 31, yb + 360, purple) % top left wall corner along y
    drawfillbox (xb + 30, yb + 350, xb + 31, yb + 370, purple) % top left wall corner along x
    drawfillbox (xb + 340, yb + 350, xb + 341, yb + 370, purple) % top right wall corner along x
    drawfillbox (xb + 590, yb + 370, xb + 591, yb + 230, purple) % top right wall corner along y
    drawfillbox (xb + 590, yb + 190, xb + 591, yb + 40, purple) % bottom right wall corner along y
    drawfillbox (xb + 350, yb + 40, xb + 351, yb + 60, purple) % bottom right wall corner along x
    drawfillbox (xb + 300, yb + 180, xb + 301, yb + 200, purple) % inner monster spawn bottom left corner along the y
    drawfillbox (xb + 280, yb + 200, xb + 281, yb + 210, purple) % inner monster spawn bottom left corner along the x
    drawfillbox (xb + 300, yb + 230, xb + 301, yb + 260, purple) % inner monster spawn top left corner along the y
    drawfillbox (xb + 280, yb + 230, xb + 281, yb + 240, purple) % inner monster spawn top left corner along the x
    drawfillbox (xb + 330, yb + 230, xb + 331, yb + 260, purple) % inner monster spawn top right corner along the y
    drawfillbox (xb + 330, yb + 230, xb + 331, yb + 240, purple) % inner monster spawn top right corner along the x
    drawfillbox (xb + 330, yb + 180, xb + 331, yb + 210, purple) % inner monster spawn bottom right corner along the y
    drawfillbox (xb + 330, yb + 200, xb + 331, yb + 210, purple) % inner monster spawn bottom right corner along the x
    drawfillbox (xb + 330, yb + 230, xb + 331, yb + 260, purple) % inner monster spawn top right corner along the y
    drawfillbox (xb + 90, yb + 150, xb + 91, yb + 250, purple) % inner left entrance
    drawfillbox (xb + 550, yb + 150, xb + 551, yb + 250, purple) % inner right entrance
    drawfillbox (xb + 280, yb + 90, xb + 281, yb + 100, purple) % inner bottom entrance
    drawfillbox (xb + 270, yb + 300, xb + 271, yb + 310, purple) % inner top entrance
    drawfillbox (xb + 80, yb + 100, xb + 81, yb + 110, purple) % inner left small wall along x
    drawfillbox (xb + 80, yb + 50, xb + 81, yb + 100, purple) % inner left bottom wall along y
    drawfillbox (xb + 50, yb + 300, xb + 51, yb + 310, purple) % inner top far left corner along the x
    drawfillbox (xb + 180, yb + 300, xb + 181, yb + 310, purple) % inner top left corner along x
    drawfillbox (xb + 210, yb + 100, xb + 211, yb + 360, purple) % inner left side along y very long line
    drawfillbox (xb + 400, yb + 220, xb + 401, yb + 230, purple) % inner right side middle  along x
    drawfillbox (xb + 400, yb + 220, xb + 401, yb + 150, purple) % inner rgit middle side along y
    drawfillbox (xb + 100, yb + 200, xb + 101, yb + 210, purple) % inner top bottom left middle along x
    drawfillbox (xb + 500, yb + 360, xb + 501, yb + 280, purple) % inner top roght corner along y
    drawfillbox (xb + 450, yb + 320, xb + 451, yb + 230, purple) % inner top right corner along y

    %yellow walls
    drawfillbox (xb + 299, yb + 40, xb + 300, yb + 60, yellow) %bottom left wall corner along x
    drawfillbox (xb + 49, yb + 40, xb + 50, yb + 180, yellow) % bottom left wall corner along y
    drawfillbox (xb + 49, yb + 230, xb + 50, yb + 360, yellow) % top left wall corner along y
    drawfillbox (xb + 299, yb + 350, xb + 300, yb + 370, yellow) % top left wall corner along x
    drawfillbox (xb + 609, yb + 370, xb + 610, yb + 230, yellow) % top right wall corner along y
    drawfillbox (xb + 609, yb + 190, xb + 610, yb + 40, yellow) % bottom right wall corner along y
    drawfillbox (xb + 599, yb + 40, xb + 600, yb + 60, yellow) % bottom right wall corner along x
    drawfillbox (xb + 309, yb + 180, xb + 310, yb + 200, yellow) % inner monster spawn bottom left corner along the y
    drawfillbox (xb + 309, yb + 200, xb + 310, yb + 210, yellow) % inner monster spawn bottom left corner along the x
    drawfillbox (xb + 309, yb + 230, xb + 310, yb + 260, yellow) % inner monster spawn top left corner along the y
    drawfillbox (xb + 309, yb + 230, xb + 310, yb + 240, yellow) % inner monster spawn top left corner along the x
    drawfillbox (xb + 339, yb + 230, xb + 340, yb + 260, yellow) % inner monster spawn top right corner along the y
    drawfillbox (xb + 359, yb + 230, xb + 360, yb + 240, yellow) % inner monster spawn top right corner along the x
    drawfillbox (xb + 339, yb + 180, xb + 340, yb + 210, yellow) % inner monster spawn bottom right corner along the y
    drawfillbox (xb + 359, yb + 200, xb + 360, yb + 210, yellow) % inner monster spawn bottom right corner along the x
    drawfillbox (xb + 339, yb + 230, xb + 340, yb + 260, yellow) % inner monster spawn top right corner along the y
    drawfillbox (xb + 99, yb + 150, xb + 100, yb + 250, yellow) % inner left entrance
    drawfillbox (xb + 559, yb + 150, xb + 560, yb + 250, yellow) % inner right entrance
    drawfillbox (xb + 379, yb + 90, xb + 380, yb + 100, yellow) % inner bottom entrance
    drawfillbox (xb + 379, yb + 300, xb + 380, yb + 310, yellow) % inner top entrance
    drawfillbox (xb + 149, yb + 100, xb + 150, yb + 110, yellow) % inner left small wall along x
    drawfillbox (xb + 89, yb + 50, xb + 90, yb + 100, yellow) % inner left bottom wall along y
    drawfillbox (xb + 149, yb + 300, xb + 150, yb + 310, yellow) % inner top far left corner along the x
    drawfillbox (xb + 239, yb + 300, xb + 240, yb + 310, yellow) % inner top left corner along x
    drawfillbox (xb + 219, yb + 100, xb + 220, yb + 360, yellow) % inner left side along y very long line
    drawfillbox (xb + 549, yb + 220, xb + 550, yb + 230, yellow) % inner right side middle  along x
    drawfillbox (xb + 409, yb + 220, xb + 410, yb + 150, yellow) % inner rgit middle side along y
    drawfillbox (xb + 179, yb + 200, xb + 180, yb + 210, yellow) % inner top bottom left middle along x
    drawfillbox (xb + 509, yb + 360, xb + 510, yb + 280, yellow) % inner top roght corner along y
    drawfillbox (xb + 459, yb + 320, xb + 460, yb + 230, yellow) % inner top right corner along y


    %walls stop muncher

    if whatdotcolour (mx, my) = 12 or whatdotcolour (mx, my) = 12 then
        my2 := my + 5
        my := my2
    end if
    if whatdotcolour (mx, my) = blue or whatdotcolour (mx, my) = blue then
        my2 := my - 5
        my := my2
    end if
    if whatdotcolour (mx, my) = yellow or whatdotcolour (mx, my) = yellow then
        mx2 := mx + 5
        mx := mx2
    end if
    if whatdotcolour (mx, my) = purple or whatdotcolour (mx, my) = purple then
        mx2 := mx - 5
        mx := mx2
    end if


    %outputs points
    Font.Draw ("Score: ", 280, 385, font3, white)



    setscreen ("offscreenonly")
    delay (10)
    View.Update
    cls

end loop

-----------------------------------
Delos
Tue Apr 27, 2004 10:09 am


-----------------------------------
Dude...

1)  If you are going to put THAT much code in your post, at least use the so much easier.  Really, it will.

4)  PM the_short1 for advice concerning anything Pacman.

-----------------------------------
MyPistolsIn3D
Sat May 01, 2004 6:45 pm


-----------------------------------
Try this: I hope its what you wanted.
%walls stop muncher 

if whatdotcolour (mx, my+5) = 12 or whatdotcolour (mx, my+5) = 12 then 
my2 := my + 5 
my := my2 
end if 
if whatdotcolour (mx, my+5) = blue or whatdotcolour (mx, my+5) = blue then 
my2 := my - 5 
my := my2 
end if 
if whatdotcolour (mx+5, my) = yellow or whatdotcolour (mx+5, my) = yellow then 
mx2 := mx + 5 
mx := mx2 
end if 
if whatdotcolour (mx+5, my) = purple or whatdotcolour (mx+5, my) = purple then 
mx2 := mx - 5 
mx := mx2 
end if 

-----------------------------------
MyPistolsIn3D
Sat May 01, 2004 6:48 pm


-----------------------------------
The way you had it before, it stopped when the middle of the oval hit the wall, now i added 5 to it, it stops when it hits the outer edge of the oval(radius of 5).
