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

Username:   Password: 
 RegisterRegister   
 PacMan's Movement
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Draconis




PostPosted: Sat May 30, 2009 11:47 am   Post subject: PacMan's Movement

What is it you are trying to achieve?
I am trying to make the Pacman to move when I press the key without having to hold it down. And I am also trying to get the Pacman to stop moving when it reaches the top wall. I am going to add the other walls after I get this one to work.


What is the problem you are having?
I have to press and hold the button for the Pacman to move. And the Pacman continues moving even when it hits the blue wall. I am not exactly sure about how I am going to add the other walls.


Describe what you have tried to solve this problem
I've tried looping it, but then the program grows unresponsive and slow, causing the Pacman to react slowly, and because this game is Pacman, it is very important that it reacts as soon as possible.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I've attached the turing file. If you're having trouble opening the file, try saving it first. Thanks! =]

Turing:


<Add your code here>



Please specify what version of Turing you are using
Turing for Windows
Version 4.0.3



PacMan6.t
 Description:
This is my summative assignment for grade 9.

Download
 Filename:  PacMan6.t
 Filesize:  1.53 KB
 Downloaded:  182 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
tjmoore1993




PostPosted: Sat May 30, 2009 4:07 pm   Post subject: RE:PacMan\'s Movement

You got to understand how Input.KeyDown works. When you defined the char it is basically defined as a boolean meaning "true" or "false".

When you press an arrow key it is returning true. What you want is the key returning a constant true value...

Doing this will require 4 separate variables
EX.

Turing:
var Left,Right,Up,Down : boolean := false

if chars (KEY_RIGHT_ARROW) then
            Up := false
            Down := false
            Left := false
            Right := true
end if

if Up = true then
y += ??
end if


I did not include all the variables and things necessary for a successful launch. Anyways, when you get the idea have a statement saying if one of the boolean types is true do an action.


Sorry for the lack of grammar used to compile this message but I am in a hurry.
tjmoore1993




PostPosted: Sat May 30, 2009 4:16 pm   Post subject: RE:PacMan\'s Movement

To add, in order to achieve the stopping of pac man upon hitting of a wall, run a hittest so that when the pac man fellow hits blue it stops. There are many ways of doing this and it isn't that hard.

I wish I could help but giving full answers is not good.
Draconis




PostPosted: Sun May 31, 2009 8:47 am   Post subject: Re: PacMan's Movement What.DotColor

Thanks for the help! Smile

About the walls, I am thinking of using What.DotColor, is this the right approach to this problem? What I am finding difficult is that Pacman moves like this, x := x + 12, so when I say to stop at a specific pixel (blue), it ignores it and continues anyways... will I end up stating many pixels, or is there a way around that?

Thanks a lot for your help!
andrew.




PostPosted: Sun May 31, 2009 9:04 am   Post subject: RE:PacMan\'s Movement

Don't use WhatDotColor. It's the worst thing you can use. Look through this for help.
Draconis




PostPosted: Tue Jun 02, 2009 4:07 pm   Post subject: Re: PacMan's Movement

I'm not sure if it's just me, but I found collision detection kind of confusing. If any has any better ideas/ways for me to make the walls, that would be highly appreciated. =) Thank you.
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: