tslusny Posted March 17, 2013 Author Share Posted March 17, 2013 Nevermind, fixed it. Correctly it should look like this:```Public Function GetSprite(ByVal Sprite As Long, ByVal Spritesheet As Long)Dim firstsprite As Long If Sprite <= 8 Then GetSprite = Sprite Exit Function Else firstsprite = 8 * (Spritesheet - 1) GetSprite = Sprite - firstsprite End IfEnd Function```Hello all ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Ik that i should know this, but i really do not like maths ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)So what i am trying to do?This is my function:```Public Function GetSpriteFromSpritesheet(ByVal Sprite As Long, ByVal Spritesheet As Long)If Sprite <= 8 ThenGetSpriteFromSpritesheet = SpriteExit FunctionElseGetSpriteFromSpritesheet = Sprite / SpritesheetEnd IfEnd Function```**Example values passed into:**Sprite: 256Spritesheet: 32Result is: 8This above value is perfectly correct, but when i put for example this:Sprite: 255Spritesheet: 32Result is: 7,96875This above value should be 7 and not 7,96875.**What i am doing wrong?** Link to comment Share on other sites More sharing options...
Matt Posted March 17, 2013 Share Posted March 17, 2013 Are you sure its 7,96875 and not 7.96875? Link to comment Share on other sites More sharing options...
cheatking Posted March 17, 2013 Share Posted March 17, 2013 > Are you sure its 7,96875 and not 7.96875?Some countries use , instead of .Truncate the value for a quick fix. Link to comment Share on other sites More sharing options...
tslusny Posted March 17, 2013 Author Share Posted March 17, 2013 Nevermind, fixed it. Correctly it should look like this:```Public Function GetSprite(ByVal Sprite As Long, ByVal Spritesheet As Long)Dim firstsprite As Long If Sprite <= 8 Then GetSprite = Sprite Exit Function Else firstsprite = 8 * (Spritesheet - 1) GetSprite = Sprite - firstsprite End IfEnd Function``` Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now