Computer Science Canada How Do U Make A Box Go Up and Down |
Author: | vi3t_4ever [ Sat May 28, 2005 12:24 pm ] |
Post subject: | How Do U Make A Box Go Up and Down |
Hey...im new here...i was just wondering if anyone can help me asap....i want to know how can u get a box moving up and down...like a elevator for the CN tower...plz help....I REALLY NEED THIS ASAP!!!!!!!!!!! |
Author: | StarGateSG-1 [ Sat May 28, 2005 12:51 pm ] |
Post subject: | |
I need more information, do you control the box? for one. Second we do not right code for you here this is were you get help! |
Author: | vi3t_4ever [ Sat May 28, 2005 12:57 pm ] |
Post subject: | |
ok...first...i need it to go up by it self...second...i know that...i just want to know wat code can can move the box up by itslef....u dont need to do it for me...and i just need something basic...not so difficult like the other ones....my teacher didnt teach me those |
Author: | StarGateSG-1 [ Sat May 28, 2005 1:03 pm ] |
Post subject: | |
Ok clear the box and redraw it in a loop. |
Author: | Cervantes [ Sat May 28, 2005 1:18 pm ] | ||||||||||
Post subject: | |||||||||||
If you want to move a box around, you cannot use hardcoded values for the x and y coordinates of the box. That is, code such as this,
will not move a box around, no matter how many times you draw it. So much should be self-evident. To move the box, you need the x and y coordinates to change. Thus, we cannot hardcode integers such as 100, 100, 200, 200. Instead, we need variables.
This does the same as the code above. However, we could now change the variables, and thereby change the position of the box. If we want to actually move the box, we need to draw the box in one position, then clear that image and draw it in another position, and repeat this process over and over. To do this, we use a loop.
Yay, the box moves up. Now, the thing is we probably don't want to have to incriment two variables just to move one box. Let's change the format of this a bit:
Now we only have to worry about one coordinate position, and with that the box will position itself. Now, to make this look smoother, we need to use View.Update. Here's how:
There are tutorials on these topics (View.Update, loops, variables, basic graphics) in the Turing Tutorials forum. Search for them if you wish. |
Author: | axej [ Wed Jun 08, 2005 5:45 pm ] |
Post subject: | |
search is now my new best friend! ok i agree this tread is old, but how do i make it stop at a certain height? |
Author: | Cervantes [ Wed Jun 08, 2005 5:57 pm ] | ||||||
Post subject: | |||||||
There are a few ways. The method you choose depends on what else is happening in your program. Method 1
This method I detest. If you want to do ANYTHING else at the same time as moving a box (such as moving a different box, drawing stuff, processing stuff, getting input, etc.) you should not use this method. Method 2
This method is much better. It allows the "object" to behave as its properties define, all while in a general loop. This allows other "objects" to be behaving as they should at the same time. Method 3
This method is essentially the same as Method 2, except it does not force us to exit when the box reaches a certain point. This allows the loop to have some other means of exitting. |
Author: | axej [ Wed Jun 08, 2005 6:09 pm ] |
Post subject: | |
thnx method one is so easy! wow. i think i'll use that so i won't have to explain everything to my teacher i don't need to do other stuff while the box moves. parallel put still works while that happens right? btw: "offscreenonly" stops flickering right? |
Author: | Cervantes [ Wed Jun 08, 2005 6:18 pm ] |
Post subject: | |
axej wrote: thnx
method one is so easy! wow. i think i'll use that so i won't have to explain everything to my teacher i don't need to do other stuff while the box moves. parallel put still works while that happens right? btw: "offscreenonly" stops flickering right? parallelput will still work, but you'll have to code it directly into the for loop, which may or may not be so pleasent. offscreenonly does not stop the flickering. To stop it, you need to set offscreenonly, then use View.Update (in the correct place, if you want to see what you intend to show). |
Author: | axej [ Wed Jun 08, 2005 8:24 pm ] |
Post subject: | |
thnx what do you think of my uber simple culminating that nobody in my class has started yet? *Edit* if your wondering why the "%parallelput", its because the actual thingy im building isn't really wired yet. i still have to get that seven segment display working. ok, second addition. the locate thingy is messed it doesn't do anything except end the program which its no tsupposed to do, any er suggestions? the code looks noobish too i just realised that, but its easy to explain it to my teacher |
Author: | Drakain Zeil [ Wed Jun 08, 2005 9:53 pm ] | ||
Post subject: | |||
You can shorten that code by... I'd say about 4/5ths. Use a for..next loop to increment that one number that you add 50 to each time. Edit: Aslo, I think you only need to set the View.Set once. Edit again!: I just took a real look into your code, and oh boy did you ever over-do it!. Try this...
|
Author: | axej [ Wed Jun 08, 2005 9:56 pm ] |
Post subject: | |
ok, how about the locate part? |
Author: | [Gandalf] [ Thu Jun 09, 2005 3:54 pm ] | ||||
Post subject: | |||||
It's alright.
should be
don't know why you have the :int... |
Author: | axej [ Thu Jun 09, 2005 4:02 pm ] |
Post subject: | |
i figured that one out already thanks |
Author: | axej [ Thu Jun 09, 2005 4:22 pm ] |
Post subject: | |
ok i have another problem i can't get my seven segment display to work can anyone help me? |
Author: | Drakain Zeil [ Thu Jun 09, 2005 5:35 pm ] |
Post subject: | |
Blah, I just cut/paste around his code, didn't look at vars. What is the problem then? Be specific, don't just say "i need help." That's great, but I have no idea what you need. |
Author: | axej [ Thu Jun 09, 2005 6:23 pm ] |
Post subject: | |
*problem solved* |
Author: | axej [ Fri Jun 10, 2005 7:57 pm ] |
Post subject: | |
ok problem three how do i get the progarm to output the floors as it goes along instead of just displaying the final floor at the very end? |
Author: | ZeroPaladn [ Sat Jun 11, 2005 8:45 am ] | ||
Post subject: | |||
ya, im a newb but i know a newbish way to fix your problem. just when the "elevator" reaches a certain co-ordinates make it display the floor. i'll post an example
i used Turing 3 for this (its all i got ) so if the code doesn't work then dont blame me blame my turing! EDIT Remind me again why were MAKING the program for you? |
Author: | Cervantes [ Sat Jun 11, 2005 9:09 am ] | ||
Post subject: | |||
Why make the for loop count from 1 to 400 when all you need is 1 to 4?
Also, you were missing an end if in your code, and you had lots of else. You can only have one per if statement. |
Author: | axej [ Sat Jun 11, 2005 9:44 am ] | ||
Post subject: | |||
what if i wanted to make it output through the parallel port like to a seven segment display? oh and i fixed my code.
|
Author: | Drakain Zeil [ Sat Jun 11, 2005 11:17 am ] | ||
Post subject: | |||
axej wrote: what if i wanted to make it output through the parallel port like to a seven segment display?
oh and i fixed my code.
Why'd you use parallelput? |
Author: | axej [ Sat Jun 11, 2005 2:13 pm ] |
Post subject: | |
i'm supposed to use turing with the parallel prot to control something. in my case its a seven segment display to show the user which floor there on |
Author: | axej [ Sat Jun 11, 2005 7:08 pm ] |
Post subject: | |
ZeroPaladn wrote: Remind me again why were MAKING the program for you?
your not MAKING the program for me and you never will. you're pointing out stupid things in MY program and helping me with things i don't knoe how to do and btw don't use caps please. this is fun |