
-----------------------------------
Dazzle
Sun Jan 27, 2013 11:03 am

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 :/

-----------------------------------
Insectoid
Sun Jan 27, 2013 12:20 pm

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.

-----------------------------------
Dazzle
Sun Jan 27, 2013 2:41 pm

RE:Gotta Question
-----------------------------------
Could you possible give me an example?

-----------------------------------
Tony
Sun Jan 27, 2013 2:46 pm

RE:Gotta Question
-----------------------------------
[code]
for i: 1..100 by 1
   Draw.FillOval(i,100,10,10,red)
   delay(100)
   cls
end for
[/code]
vs.
[code]
for i: 1..100 by 10
   Draw.FillOval(i,100,10,10,red)
   delay(100)
   cls
end for
[/code]

-----------------------------------
Dazzle
Sun Jan 27, 2013 3:20 pm

RE:Gotta Question
-----------------------------------
Im sorry i do not understand that :P lol
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

-----------------------------------
Tony
Sun Jan 27, 2013 5:00 pm

RE:Gotta Question
-----------------------------------
instead of taking one big step (32 pixels), take two smaller steps (16 pixels each).

-----------------------------------
Dazzle
Sun Jan 27, 2013 5:11 pm

RE:Gotta Question
-----------------------------------
but how would i do that?? :O

-----------------------------------
Tony
Sun Jan 27, 2013 6:12 pm

RE:Gotta Question
-----------------------------------
What have you tried so far? You could refer to the examples above, when trying to come up with a design.

-----------------------------------
Dazzle
Sun Jan 27, 2013 6:29 pm

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

-----------------------------------
Tony
Sun Jan 27, 2013 6:57 pm

RE:Gotta Question
-----------------------------------
what kind of an error?

-----------------------------------
Dazzle
Sun Jan 27, 2013 10:06 pm

RE:Gotta Question
-----------------------------------
Assigned Value Is the Wrong Type.

-----------------------------------
Tony
Mon Jan 28, 2013 2:41 am

RE:Gotta Question
-----------------------------------
Turing is strongly typed, so the type of variable and the values assigned to it must match up.
[code]
var count : int := "some text"
put count
[/code]
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.

-----------------------------------
Dazzle
Mon Jan 28, 2013 9:57 am

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?

-----------------------------------
DemonWasp
Mon Jan 28, 2013 10:09 am

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.

-----------------------------------
Dazzle
Mon Jan 28, 2013 10:50 am

RE:Gotta Question
-----------------------------------
ok.. i kinda get it so it would be like this??

var number : int :=float(5)

?

-----------------------------------
Raknarg
Mon Jan 28, 2013 12:49 pm

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.

-----------------------------------
Dazzle
Mon Jan 28, 2013 9:10 pm

RE:Gotta Question
-----------------------------------
ohhhhhh.... OMG thank you soo much.. im gunna try it now i hope it works :)

-----------------------------------
Dazzle
Mon Jan 28, 2013 9:37 pm

Re: Gotta Question
-----------------------------------
ok so.. i get it but its not working :/ heres the code im working with

[code]
loop

    reDraw 
    Input.KeyDown (key) 
    if key ('a') and tiles (px - 1, py) = 0 then
     var player_movement : real :=0.25
        px -=player_movement Pic.Draw (wizard3 ,px * 32, py * 32,0)
        View.Update
    end if 
    if key ('d') and tiles (px + 1, py) = 0 then 
        movement Pic.Draw (wizard1 ,px * 32, py * 32,0)
        View.Update
    end if 
    if key('s') and tiles (px , py - 1) = 0 then
        movement Pic.Draw (wizard2 ,px * 32, py * 32,0)
        View.Update
        end if
    if key ('w') and tiles (px , py + 1) = 0 then 
        movement Pic.Draw (wizard0 ,px * 32, py * 32,0)
        View.Update
    end if  
    delay (50) 
end loop
[/code]

Got any ideas??

-----------------------------------
Tony
Tue Jan 29, 2013 12:12 am

RE:Gotta Question
-----------------------------------
[code]
var player_movement : real :=0.25 
        px -=player_movement
[/code]
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?

-----------------------------------
Dazzle
Tue Jan 29, 2013 12:54 am

RE:Gotta Question
-----------------------------------
after payer_movement..

like this?????

px -=player_movement : real:=0.25

-----------------------------------
Tony
Tue Jan 29, 2013 3:12 am

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!

-----------------------------------
Dazzle
Tue Jan 29, 2013 7:46 am

RE:Gotta Question
-----------------------------------
yea.. lol i did try. ;p .. but here ill ask agan how can i move by pixels not tiles?

-----------------------------------
Insectoid
Tue Jan 29, 2013 2:00 pm

RE:Gotta Question
-----------------------------------
[code]Pic.Draw (wizard1 ,px * 32, py * 32,0) [/code]

As long as you're drawing to px*32, py*32, you will not be able to move by pixels.

-----------------------------------
Tony
Tue Jan 29, 2013 3:25 pm

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.

-----------------------------------
Dazzle
Tue Jan 29, 2013 5:02 pm

RE:Gotta Question
-----------------------------------
could you possible make a snippet for the mechanisim

-----------------------------------
Dazzle
Wed Feb 13, 2013 10:24 am

RE:Gotta Question
-----------------------------------
Could you please help ive been w8ing for a while and there has been no answer
