
-----------------------------------
crush_soda
Sun Oct 23, 2011 8:47 pm

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



I can not get the rectangle to move



I'm trying to use input.keydown but i can't get it to work!





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









Turing for windows, 4.1.1 


-----------------------------------
Tony
Sun Oct 23, 2011 9:03 pm

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) ?

-----------------------------------
crush_soda
Sun Oct 23, 2011 9:16 pm

Re: 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) ?

i have no idea

do you know how to make the rectangle move using input.keydown?

-----------------------------------
Tony
Sun Oct 23, 2011 9:17 pm

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.

-----------------------------------
crush_soda
Sun Oct 23, 2011 9:20 pm

Re: 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.

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
Sun Oct 23, 2011 9:27 pm

RE:How to make a rectangle slide without going off screen
-----------------------------------
Draw it at a different location. 5,0 perhaps?

-----------------------------------
crush_soda
Sun Oct 23, 2011 9:32 pm

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
Sun Oct 23, 2011 9:39 pm

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.

-----------------------------------
crush_soda
Sun Oct 23, 2011 9:44 pm

Re: 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.
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
Sun Oct 23, 2011 9:59 pm

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. 


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
Sun Oct 23, 2011 10:07 pm

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
Sun Oct 23, 2011 10:07 pm

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
Sun Oct 23, 2011 10:09 pm

Re: 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.

yahoo answers takes like 25 years for someone to reply...

-----------------------------------
Raknarg
Sun Oct 23, 2011 10:11 pm

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.

yahoo answers takes like 25 years for someone to reply... 

Yes, plus the answers are usually troll garbage

-----------------------------------
Zren
Mon Oct 24, 2011 2:36 am

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.

-----------------------------------
evildaddy911
Mon Oct 24, 2011 7:09 am

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

-----------------------------------
Aange10
Mon Oct 24, 2011 7:37 am

Re: How to make a rectangle slide without going off screen
-----------------------------------

TIP: you can use variables for drawfillbox parameters

with a little editing...

 TIP: use variables for drawfillbox parameters 

-----------------------------------
tg851
Fri Nov 04, 2011 10:09 am

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)



var y1,x1,x2,y2 :int
y1:=10
x1:=10
x2:=20
y2:=20

var chars : array char of boolean 
        loop 
            Input.KeyDown (chars) 
        drawfillbox (x1,y1,x2,y2,black)
            %the movment code

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)

-----------------------------------
matthewrohaly
Fri Nov 04, 2011 10:55 am

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)



var y1,x1,x2,y2 :int
y1:=10
x1:=10
x2:=20
y2:=20

var chars : array char of boolean 
        loop 
            Input.KeyDown (chars) 
        drawfillbox (x1,y1,x2,y2,black)
            %the movment code

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.
