Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Gotta Question
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dazzle




PostPosted: 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 :/
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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.
Dazzle




PostPosted: Sun Jan 27, 2013 2:41 pm   Post subject: RE:Gotta Question

Could you possible give me an example?
Tony




PostPosted: Sun Jan 27, 2013 2:46 pm   Post subject: RE:Gotta Question

code:

for i: 1..100 by 1
   Draw.FillOval(i,100,10,10,red)
   delay(100)
   cls
end for

vs.
code:

for i: 1..100 by 10
   Draw.FillOval(i,100,10,10,red)
   delay(100)
   cls
end for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dazzle




PostPosted: Sun Jan 27, 2013 3:20 pm   Post subject: RE:Gotta Question

Im sorry i do not understand that Razz 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




PostPosted: 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).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dazzle




PostPosted: Sun Jan 27, 2013 5:11 pm   Post subject: RE:Gotta Question

but how would i do that?? :O
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Dazzle




PostPosted: 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
Tony




PostPosted: Sun Jan 27, 2013 6:57 pm   Post subject: RE:Gotta Question

what kind of an error?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dazzle




PostPosted: Sun Jan 27, 2013 10:06 pm   Post subject: RE:Gotta Question

Assigned Value Is the Wrong Type.
Tony




PostPosted: 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.
code:

var count : int := "some text"
put count

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dazzle




PostPosted: 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?
DemonWasp




PostPosted: 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.
Dazzle




PostPosted: 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)

?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 26 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: