Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Need help creating boundaries for a maze game
Author Message
MI

Posted: Wed Mar 27, 2013 2:30 am   Post subject: Need help creating boundaries for a maze game

I am trying to make a maze game using Turing. I REALLY need help making the maze walls. I want my character to move through the maze and not be able to walk right through the maze walls. How do I create boundaries?

Any help is appreciated:)

Describe what you have tried to solve this problem
I tried looking at forums and Turing game examples but it's really difficult to understand.
I am kinda new to this program.

Please specify what version of Turing you are using
Turing 4.1.1

Nathan4102

Posted: Wed Mar 27, 2013 7:47 am   Post subject: RE:Need help creating boundaries for a maze game

Hmm, You could draw your lines using the turing graphics functions, and then create an imaginary boundary one pixel away from that line. Then every time you try to move, turing will check if we are standing on one of these imaginary boundaries. If we are, don't move? If you need explanation, I could probably code a small example.
Raknarg

Posted: Wed Mar 27, 2013 1:10 pm   Post subject: RE:Need help creating boundaries for a maze game

 Turing: var x, y : int if x > maxx then     x := maxx elsif x < 0 then     x := 0 end if if y > maxy then     y := maxy elsif y < 0 then     y := 0 end if

Think about it. If you're past a bound, basically set the thing behind or on the bound. Now x and y won't escape the screen.
MI

Posted: Wed Mar 27, 2013 9:19 pm   Post subject: Re: RE:Need help creating boundaries for a maze game

Raknarg @ Wed Mar 27, 2013 1:10 pm wrote:
 Turing: var x, y : int if x > maxx then     x := maxx elsif x < 0 then     x := 0 end if if y > maxy then     y := maxy elsif y < 0 then     y := 0 end if

I am not getting how exactly to add it to my code. Suppose I want (just for an example) a character to go through a maze and I don't want it to be able to pass a maze wall:

var x, y : int
x := 100
y := 100

var chars : array char of boolean
loop

Input.KeyDown (chars)

if chars (KEY_UP_ARROW) then
y := y + 5
elsif chars (KEY_RIGHT_ARROW) then
x := x + 5

elsif chars (KEY_LEFT_ARROW) then
x := x - 5

elsif chars (KEY_DOWN_ARROW) then
y := y - 5
end if

drawfilloval (x, y, 10,10, blue)
delay (10)
cls
drawline (0,50,500,50,black)
end loop

In this above code, how can I make the circle not be able to go past the line? I know you already gave me the idea but I just don't know how to add it to this. Please help! Thank you so much Oh and if possible, do you know how to make the flashing stop?
MI

Posted: Wed Mar 27, 2013 9:23 pm   Post subject: Re: RE:Need help creating boundaries for a maze game

Nathan4102 @ Wed Mar 27, 2013 7:47 am wrote:
Hmm, You could draw your lines using the turing graphics functions, and then create an imaginary boundary one pixel away from that line. Then every time you try to move, turing will check if we are standing on one of these imaginary boundaries. If we are, don't move? If you need explanation, I could probably code a small example.

Here's my example of a code (a moving circle as a character and a line as a maze wall):

 Turing: var x, y : int x := 100 y := 100 var chars : array char of boolean loop     Input.KeyDown (chars)     if chars (KEY_UP_ARROW) then         y := y + 5    elsif chars (KEY_RIGHT_ARROW) then         x := x + 5         elsif chars (KEY_LEFT_ARROW) then         x := x - 5         elsif chars (KEY_DOWN_ARROW) then         y := y - 5     end if         drawfilloval (x, y, 10,10, blue)     delay (10)     cls drawline (0,50,500,50,black) end loop

How would I add boundaries to the line so that the circle can't go past the line and instead, collide with it?
Dragon20942

Posted: Fri Mar 29, 2013 4:01 pm   Post subject: RE:Need help creating boundaries for a maze game

It will be an if statement.

Pseudocode:

if the character's position is beyond the boundary
reverse the action that caused it to happen
end if
Cancer Sol

Posted: Fri Mar 29, 2013 4:14 pm   Post subject: Re: Need help creating boundaries for a maze game

Quote:
If you're past a bound, basically set the thing behind or on the bound.

Omg, that's so smart
I never thought of that before
Zren

Posted: Fri Mar 29, 2013 6:12 pm   Post subject: RE:Need help creating boundaries for a maze game

Instead of moving the variable back (to most likely a constant location), don't move it at all in the first place. Use a temporary variable to calculate it's destination. Then, if that destination is valid, assign the value.

Raknarg

Posted: Sat Mar 30, 2013 8:41 pm   Post subject: RE:Need help creating boundaries for a maze game

That's how they do vector collision, right?
MI

Posted: Tue Apr 02, 2013 4:12 pm   Post subject: RE:Need help creating boundaries for a maze game

Thank you guys!!! I think I got it
basi

Posted: Thu Mar 28, 2019 10:39 am   Post subject: Re: RE:Need help creating boundaries for a maze game

MI @ Wed Mar 27, 2013 9:19 pm wrote:
Raknarg @ Wed Mar 27, 2013 1:10 pm wrote:
 Turing: var x, y : int if x > maxx then     x := maxx elsif x < 0 then     x := 0 end if if y > maxy then     y := maxy elsif y < 0 then     y := 0 end if

I am not getting how exactly to add it to my code. Suppose I want (just for an example) a character to go through a maze and I don't want it to be able to pass a maze wall:

var x, y : int
x := 100
y := 100

var chars : array char of boolean
loop

Input.KeyDown (chars)

if chars (KEY_UP_ARROW) then
y := y + 5
elsif chars (KEY_RIGHT_ARROW) then
x := x + 5

elsif chars (KEY_LEFT_ARROW) then
x := x - 5

elsif chars (KEY_DOWN_ARROW) then
y := y - 5
end if

drawfilloval (x, y, 10,10, blue)
delay (10)
cls
drawline (0,50,500,50,black)
end loop

In this above code, how can I make the circle not be able to go past the line? I know you already gave me the idea but I just don't know how to add it to this. Please help! Thank you so much Oh and if possible, do you know how to make the flashing stop?

you can stop the flasing by doing this
View.Set ("graphics:350;400,offscreenonly")
its what i did, it should work to stop the flickering
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 11 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: