Fastest way to move a sprite

Advanced game related topics
dan yalte
User
User
Posts: 50
Joined: Thu Aug 13, 2015 8:56 am

Fastest way to move a sprite

Post by dan yalte »

I have some code i wrote a while back not handy at the moment that moves card sprites for a game .The code uses a loop to move the sprites from point A to B. The issue is that it's kinda slow what's the best way to make suck a thing move faster across the screen and is there any way to very the speed at all. Any help would be cool thanks..
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Fastest way to move a sprite

Post by Demivec »

eddy's post Module - Animation & Motion tween FX contains some great functions to help out with the timing of animations.


Did you ever finish your program or are you just trying to tune it up?
dan yalte
User
User
Posts: 50
Joined: Thu Aug 13, 2015 8:56 am

Re: Fastest way to move a sprite

Post by dan yalte »

Trying to tune things up. it's a blackjack simulator. I ran into an issue with other things as well. aka the Random number generator for one but it was using an older version of the compiler.When i update the compiler I will update and audit all the code when i get it running the way i want most of the changes in commands are small but it will still help cut the size of the code a fair bit. also with a stronger Random number generator. The simulator should work as expected.

I dealt Cards in casino's for years here in Canada so i know what it should show based on the rules used to play by. I also know how the rules change the game also. So i know what i should see.

It will take a fair amount of work to get it to where i want it. I got the idea from an older program for windows 3.1 called sage blackjack. I can run it a few different ways on Linux but i want to do something better and more up to date.
marc_256
Addict
Addict
Posts: 835
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Fastest way to move a sprite

Post by marc_256 »

@dan yalte,

For my 2D game engine I use a lot of 2D gaming math ...
And to do that LINEAR motions you need, a "LERP" motion calculation (please look on the internet)


Example:
CardPointA(X,Y)
CardPointB(X,Y)

your CardPointA = Begin of Lerp = 0%
your CardPointB = End of Lerp = 100%

So, your CardMotionX = CardPointA(X)+LerpX%
And your CardMotionY = CardPointA(Y)+LerpY%

Marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
Post Reply