Computer Science Canada Gotta Question |
Author: | Dazzle [ Sun Jan 27, 2013 11:03 am ] |
Post subject: | Gotta Question |
hello i have aslight problem and i was wondering if you could help its a 2d rpg and wen i move a space it moves a whole tile and i was wondering if there was a way to smooth out the movement... i looked it up on google and i found a couple but i dont understand them :/ |
Author: | Insectoid [ Sun Jan 27, 2013 12:20 pm ] |
Post subject: | RE:Gotta Question |
Use an animation procedure. Instead of just jumping the character from tile 1 to tile 2 when a key is pressed, activate an animation to move the character across tiles pixel by pixel. |
Author: | Dazzle [ Sun Jan 27, 2013 2:41 pm ] |
Post subject: | RE:Gotta Question |
Could you possible give me an example? |
Author: | Tony [ Sun Jan 27, 2013 2:46 pm ] | ||||
Post subject: | RE:Gotta Question | ||||
vs.
|
Author: | Dazzle [ Sun Jan 27, 2013 3:20 pm ] |
Post subject: | RE:Gotta Question |
Im sorry i do not understand that ![]() umm heres an example of what im using this is code for the picture [code] if tiles (x, y) = 1 then Pic.Draw (tree, x * 32, y * 32,0) [code] and this is how it moves [code] if key ('a') and tiles (px - 1, py) = 1 then px-= 1 Pic.Draw (wizard3 ,px * 32, py * 32,0) View.Update end if [code] But i cant figure out how to make it smooth |
Author: | Tony [ Sun Jan 27, 2013 5:00 pm ] |
Post subject: | RE:Gotta Question |
instead of taking one big step (32 pixels), take two smaller steps (16 pixels each). |
Author: | Dazzle [ Sun Jan 27, 2013 5:11 pm ] |
Post subject: | RE:Gotta Question |
but how would i do that?? :O |
Author: | Tony [ Sun Jan 27, 2013 6:12 pm ] |
Post subject: | RE:Gotta Question |
What have you tried so far? You could refer to the examples above, when trying to come up with a design. |
Author: | Dazzle [ Sun Jan 27, 2013 6:29 pm ] |
Post subject: | RE:Gotta Question |
no, i am just wondering how i could move at that speed wen i try to change the speed to under 1 is just gives me and errror..?? but how do i move at pixels |
Author: | Tony [ Sun Jan 27, 2013 6:57 pm ] |
Post subject: | RE:Gotta Question |
what kind of an error? |
Author: | Dazzle [ Sun Jan 27, 2013 10:06 pm ] |
Post subject: | RE:Gotta Question |
Assigned Value Is the Wrong Type. |
Author: | Tony [ Mon Jan 28, 2013 2:41 am ] | ||
Post subject: | RE:Gotta Question | ||
Turing is strongly typed, so the type of variable and the values assigned to it must match up.
Here it's not at all clear what integer value a text is suppost to represent, so an error is thrown. It works the same way for real values and integers. To make it clear to the compiler that you know what you are doing, you'd have to build in your conversions yourself, such as rounding the numbers the way that you want. |
Author: | Dazzle [ Mon Jan 28, 2013 9:57 am ] |
Post subject: | RE:Gotta Question |
i am a beginner .. and i dont understand everything that poeple are say would you like me to put the code that im using in here? |
Author: | DemonWasp [ Mon Jan 28, 2013 10:09 am ] |
Post subject: | RE:Gotta Question |
You should generally paste the relevant code whenever it changes. I'll explain what Tony is saying though: In short, you're trying to put a square peg into a round hole. When you make a variable have type "int", it can only hold "integer" values, such as 1, 2, 3, -17, etc. It can't hold values like 0.5 or 3/4 (which are called "real" numbers, or "floating point" in computers). Turing is trying to tell you this. The assigned value of 0.5 or whatever is the wrong type for the variable's type, which is integer. If you need to represent fractional numbers, then you should use the type real (commonly called "float" or "double" in other languages. |
Author: | Dazzle [ Mon Jan 28, 2013 10:50 am ] |
Post subject: | RE:Gotta Question |
ok.. i kinda get it so it would be like this?? var number : int :=float(5) ? |
Author: | Raknarg [ Mon Jan 28, 2013 12:49 pm ] |
Post subject: | RE:Gotta Question |
Nope, because the number you set is already an integer type, not a real type. Instead of var integerNumber : int, you want var realNumber : real. Classify it as a real, not an int. |
Author: | Dazzle [ Mon Jan 28, 2013 9:10 pm ] |
Post subject: | RE:Gotta Question |
ohhhhhh.... OMG thank you soo much.. im gunna try it now i hope it works ![]() |
Author: | Dazzle [ Mon Jan 28, 2013 9:37 pm ] | ||
Post subject: | Re: Gotta Question | ||
ok so.. i get it but its not working :/ heres the code im working with
Got any ideas?? |
Author: | Tony [ Tue Jan 29, 2013 12:12 am ] | ||
Post subject: | RE:Gotta Question | ||
That takes care of the first of four steps, but currently you have no way of remembering that those steps began to happen. When should you do the second 0.25? |
Author: | Dazzle [ Tue Jan 29, 2013 12:54 am ] |
Post subject: | RE:Gotta Question |
after payer_movement.. like this????? px -=player_movement : real:=0.25 |
Author: | Tony [ Tue Jan 29, 2013 3:12 am ] |
Post subject: | RE:Gotta Question |
I don't understand what you mean. But unlike many other subjects, the awesome part about CS is that you can actually just try things out and see what the compiler thinks about it! |
Author: | Dazzle [ Tue Jan 29, 2013 7:46 am ] |
Post subject: | RE:Gotta Question |
yea.. lol i did try. ;p .. but here ill ask agan how can i move by pixels not tiles? |
Author: | Insectoid [ Tue Jan 29, 2013 2:00 pm ] | ||
Post subject: | RE:Gotta Question | ||
As long as you're drawing to px*32, py*32, you will not be able to move by pixels. |
Author: | Tony [ Tue Jan 29, 2013 3:25 pm ] |
Post subject: | RE:Gotta Question |
quarter-tile steps are fine -- e.g. round(0.25 * 32). But there needs to be a mechanism to remember to take the other 3 steps during the following game frames. |
Author: | Dazzle [ Tue Jan 29, 2013 5:02 pm ] |
Post subject: | RE:Gotta Question |
could you possible make a snippet for the mechanisim |
Author: | Dazzle [ Wed Feb 13, 2013 10:24 am ] |
Post subject: | RE:Gotta Question |
Could you please help ive been w8ing for a while and there has been no answer |