Computer Science Canada Movement Based Maze Game - Help With Wall Detection |
Author: | born-to-die [ Sun Jun 01, 2008 1:13 pm ] |
Post subject: | Movement Based Maze Game - Help With Wall Detection |
Uh I was making this game then kinda changed it a little and made it more simple because I have limited time...so I'm just making a Maze type game where your character is arrow key-controlled. I've yet to even make a level, but I have the character and movement down. I've also managed to keep him inside the walls of the output window...but anyways to my question...once I make all the walls of the maze I would like to know how to keep him from going through them...I was thinking of just putting all the outside co-ordinates of the lines or boxes inside my loop which is how i kept him from going offscreen...but if I did that it would be tedious and it would take alot of 'ands'...any help? View.Set ("offscreenonly") var x, y : int x := 10 y := 10 var chars : array char of boolean loop Input.KeyDown (chars) if chars (KEY_UP_ARROW) and y < maxy - 5 then y := y + 3 end if if chars (KEY_RIGHT_ARROW) and x < maxx - 5 then x := x + 3 end if if chars (KEY_LEFT_ARROW) and x > 5 then x := x - 3 end if if chars (KEY_DOWN_ARROW) and y > 5 then y := y - 3 end if drawfilloval (x, y, 4, 4, 7) View.Update delay (10) cls end loop |
Author: | TheGuardian001 [ Sun Jun 01, 2008 5:27 pm ] | ||
Post subject: | Re: Movement Based Maze Game - Help With Wall Detection | ||
I know everyone will probably say this is an inefficient way to do collision detection, but in this case the best way is to use the View.WhatDotColour command. basicly
it checks to see the colour of the pixel one space left of the player. if it isnt the wall colour, it lets the player move.[/b] |
Author: | Insectoid [ Sun Jun 01, 2008 5:38 pm ] |
Post subject: | RE:Movement Based Maze Game - Help With Wall Detection |
There is a tutorial somewhere on whatdotcolor. I'm feeling lazy today, so you're going to have to search it. |