Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Moving a sprite?  (Read 2158 times)

0 Members and 1 Guest are viewing this topic.

Diaf

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • View Profile
Moving a sprite?
« on: July 22, 2009, 11:32:53 AM »

OK I may be doing this very badly since our game is 3D so we have not looked at sprites and stuff much at all.

We have a character that wants to throw something. So we figured we'd just have a 3D model with a 'throwing' animation and once it plays we'll draw a sprite to screen and then use a loop to movie it across the screen till it gets where it needs to be.

So I made an entity which contains the image of the thrown item, and in the script I have this code:

Code: [Select]

        var thrown = Scene.LoadEntity("entities\item\item.entity");

thrown.SkipTo(4355, 725);
thrown.Visible = true;

while(thrown.X != 4665)
{
thrown.SkipTo((thrown.X + 10), 725);
Sleep(100);
}


Is there a more elegant or better looking way to do this?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Moving a sprite?
« Reply #1 on: July 22, 2009, 03:04:07 PM »

I don't think that throwing anything using the straight line works well... You should check this site for some inspiration and then use a curve for throwing instead of standard line. Note that two things appear when you throw an item - 1. it goes along a curved trajectory, 2. it changes speed. Both can be easily achieved in wme. Speed via the Sleep() and trajectory via x,y position.

To make the game faster, I always precalculate the trajectories into numeric delta value arrays and then simply read through the array and apply dx and dy to the item. This way it works without a glitch and nicely in the realtime.

http://www.knifethrowing.info/physics_of_knife_throwing.html

Edit: 3. It also rotates along it's axis. You can do this using the Rotate parameter of an entity.
« Last Edit: July 22, 2009, 03:10:44 PM by metamorphium »
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
 

Page created in 0.046 seconds with 21 queries.