Computer Science Canada How to make a rectangle slide without going off screen |
Author: | crush_soda [ 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 for windows, 4.1.1 <Answer Here> |
Author: | Tony [ 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) ? |
Author: | crush_soda [ 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? |
Author: | Tony [ 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. |
Author: | crush_soda [ 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? |
Author: | Tony [ 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? |
Author: | crush_soda [ 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! |
Author: | Tony [ 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. |
Author: | crush_soda [ 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. |
Author: | Aange10 [ 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 |
Author: | Raknarg [ 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. |
Author: | crush_soda [ 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! |
Author: | crush_soda [ 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... |
Author: | Raknarg [ 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 |
Author: | Zren [ 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. |
Author: | evildaddy911 [ Mon Oct 24, 2011 7:09 am ] |
Post subject: | Re: How to make a rectangle slide without going off screen |
zren is right. what you need to do is use those x and y variables that you created. other than that everything else is almost perfect TIP: you can use variables for drawfillbox parameters EDIT: Oh and if you arent using the procedure Start anywhere else, then take it out. Cuz then you need to put Start to run the procedure |
Author: | Aange10 [ Mon Oct 24, 2011 7:37 am ] |
Post subject: | Re: How to make a rectangle slide without going off screen |
evildaddy911 @ 24/10/2011, 6:09 am wrote: TIP: you can use variables for drawfillbox parameters with a little editing... TIP: use variables for drawfillbox parameters |
Author: | tg851 [ Fri Nov 04, 2011 10:09 am ] | ||
Post subject: | Re: How to make a rectangle slide without going off screen | ||
pardon me while i go bang my head against a wall.... here you can haz proper varibal set,the movment is up to you(hint:its a pain in the ass)
have fun,also stopping the box from leaving the screen is HARD(don't count on it unless you have a good grip of Turing) |
Author: | matthewrohaly [ Fri Nov 04, 2011 10:55 am ] | ||
Post subject: | Re: How to make a rectangle slide without going off screen | ||
tg851 @ Fri Nov 04, 2011 10:09 am wrote: pardon me while i go bang my head against a wall....
here you can haz proper varibal set,the movment is up to you(hint:its a pain in the ass)
have fun,also stopping the box from leaving the screen is HARD(don't count on it unless you have a good grip of Turing) tg851, even though someone may not understand or may have said the wrong thing doesn't mean you need to impolite about it. People come here for help, and we are here to assist, not to offend. Please think about what you are writing before posting, people are only looking for help. |