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

Username:   Password: 
 RegisterRegister   
 How to make a rectangle slide without going off screen
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
crush_soda




PostPosted: Sun Oct 23, 2011 8:47 pm   Post subject: How to make a rectangle slide without going off screen

I am trying to make a game where theres a sliding bar at the bottom thats supposed to move when arrow keys are pressed
<Replace all the <> with your answers/code and remove the <>>


I can not get the rectangle to move
<Answer Here>


I'm trying to use input.keydown but i can't get it to work!
<Answer Here>




var chars : array char of boolean
drawfillbox (0, 0, 60, 5, 53)

procedure start
loop

Input.KeyDown (chars)

if chars (KEY_RIGHT_ARROW) then
x := x + 5
elsif chars (KEY_LEFT_ARROW) then
x := x - 5
elsif chars (KEY_UP_ARROW) then
y := y + 5
elsif chars (KEY_DOWN_ARROW) then
y := y - 5
end if
drawfillbox (0, 0, 60, 5, 53)
delay (10)

end loop
end start

<Answer Here>

Turing:


<Add your code here>



Turing for windows, 4.1.1
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Oct 23, 2011 9:03 pm   Post subject: RE:How to make a rectangle slide without going off screen

what is the relationship between the value of x and drawfillbox (0, 0, 60, 5, 53) ?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
crush_soda




PostPosted: Sun Oct 23, 2011 9:16 pm   Post subject: Re: RE:How to make a rectangle slide without going off screen

Tony @ Sun Oct 23, 2011 9:03 pm wrote:
what is the relationship between the value of x and drawfillbox (0, 0, 60, 5, 53) ?


i have no idea

do you know how to make the rectangle move using input.keydown?
Tony




PostPosted: Sun Oct 23, 2011 9:17 pm   Post subject: RE:How to make a rectangle slide without going off screen

that box will always be drawn starting at 0,0 because those are the numbers that you've specified for it. There is absolutely no relationship to the keyboard input.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
crush_soda




PostPosted: Sun Oct 23, 2011 9:20 pm   Post subject: Re: RE:How to make a rectangle slide without going off screen

Tony @ Sun Oct 23, 2011 9:17 pm wrote:
that box will always be drawn starting at 0,0 because those are the numbers that you've specified for it. There is absolutely no relationship to the keyboard input.


okay
so forget about that then
how is this rectangle, starting at 0,0 supposed to move to the right when the right arrow key is pressed?
Tony




PostPosted: Sun Oct 23, 2011 9:27 pm   Post subject: RE:How to make a rectangle slide without going off screen

Draw it at a different location. 5,0 perhaps?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
crush_soda




PostPosted: Sun Oct 23, 2011 9:32 pm   Post subject: Re: RE:How to make a rectangle slide without going off screen

Write a Turing program that will move a rectangle on the screen left or right. The size of the rectangle must be between 10 and 400 pixels.
If the rectangle reaches an edge of the screen, it will remain there.

thats my problem
and nothing im doing is working!!!
any help would be greatly appreciated!
Tony




PostPosted: Sun Oct 23, 2011 9:39 pm   Post subject: RE:How to make a rectangle slide without going off screen

That's not your problem. That is your assignment. Your problem is that your approach is not working. It's not working because you always draw your box at the same values.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
crush_soda




PostPosted: Sun Oct 23, 2011 9:44 pm   Post subject: Re: RE:How to make a rectangle slide without going off screen

Tony @ Sun Oct 23, 2011 9:39 pm wrote:
That's not your problem. That is your assignment. Your problem is that your approach is not working. It's not working because you always draw your box at the same values.

BRO ive been working on this for the past THREE DAYS.
so heres a thought; dont make assumptions. either help people by answering there questions or just dont say anything.

I TRIED MOVING MY BOX
YOU DONT UNDERSTAND MY QUESTION.
Aange10




PostPosted: Sun Oct 23, 2011 9:59 pm   Post subject: RE:How to make a rectangle slide without going off screen

He understands your question, crush. If you're looking to flame you've definitely come to the wrong place. He told you to try re drawing your box at different values.

crush_soda wrote:

BRO ive been working on this for the past THREE DAYS.
so heres a thought; dont make assumptions. either help people by answering there questions or just dont say anything.


Bro, you must be the only person to have ever worked so hard!! ... Here's a thought: don't make assumptions about things you don't know. Either take the help you're given, or get out
Raknarg




PostPosted: Sun Oct 23, 2011 10:07 pm   Post subject: RE:How to make a rectangle slide without going off screen

In case no one has told you yet, we're not just going to spoon feed you solutions. Thats what Yahoo Answers is for.
crush_soda




PostPosted: Sun Oct 23, 2011 10:07 pm   Post subject: Re: RE:How to make a rectangle slide without going off screen

k sorry guys!
didn't mean to cause any trouble

i'll take the help i get, thanks very much!
crush_soda




PostPosted: Sun Oct 23, 2011 10:09 pm   Post subject: Re: RE:How to make a rectangle slide without going off screen

Raknarg @ Sun Oct 23, 2011 10:07 pm wrote:
In case no one has told you yet, we're not just going to spoon feed you solutions. Thats what Yahoo Answers is for.


yahoo answers takes like 25 years for someone to reply...
Raknarg




PostPosted: Sun Oct 23, 2011 10:11 pm   Post subject: RE:How to make a rectangle slide without going off screen

So here is your problem. You have specific parameters of the screen (ex the x axis is 500 and the y axis is 500). You have an object that moves on this screen. You dont want it to move:

1. right if the x is too high
2. left if the x is too low
3. up if the y is too high
4. down if the y is too low.

Using this information and some well placed if statements, you should find a proper solution.
Notice how I havent said anything you dont already know. I just reworded it.

Quote:
yahoo answers takes like 25 years for someone to reply...


Yes, plus the answers are usually troll garbage
Zren




PostPosted: Mon Oct 24, 2011 2:36 am   Post subject: RE:How to make a rectangle slide without going off screen

Constants are data that does not change throughout the program. The numbers you write in your code are constants. When you say a += 5. The variable a will increment by 5. During the entire execution of your code, that line will always increment by 5. If I wanted it to increment by 4, I'd have to change it manually, then recompile and run the code.

This is what you are probably currently doing. Changing the numbers manually. Let's look at drawfillbox (0, 0, 60, 5, 53). I see numbers that are constant. No matter what, during the execution of this code, they will never change. Therefore, the box will not move from being drawn between the points (0,0) and (60, 5). You desire the box to move. To change it's position. Using a constant to draw where your box is, is not the answer.

Oh and I doubt Yahoo Answers knows jack about Turing, as the language is used only in Canada for educational use.
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 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: