Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Animated Sprite Help

Author
Message
His Imperial Majesty
18
Years of Service
User Offline
Joined: 19th Sep 2007
Location: Throne World of Korhal
Posted: 4th Sep 2010 08:40 Edited at: 4th Sep 2010 08:41
Hi all,

I've been digging through the forums and trying to understand how I can make animated sprites work and I am having a lot of difficulty getting it right. Even copying working code and trying to adjust it to my needs fails.

What I'm trying to do is have player's character move around a room. The room is represented by a .png image that is split into a 7x7 grid of 30px long by 30px wide squares. The room is also represented by a 9x9 array called map(). Map() is defined below but essentially it is filled with 1s and 0s, a 1 indicating that that cell is filled and cannot be entered by the player while a 0 means the cell is empty.

As the code works right now, the player can move his character throughout the room but the sprite used is a single image (facing down) and not animated. It "jumps" between each 30px wide and long square. What I would like to happen is have the sprite animated so that it looks like the character is walking throughout the room using the Sprite Sheet "playerwalk.png". What I need, though, when the character moves is to have its separate frames play over the 30px difference between squares so that the animation is finished playing when it reaches the next square. Then, the character sprite will be in a "standing still" position until another arrow key is pressed.

Any help or suggestions would be greatly appreciated and many thanks in advance for any.

Images used can be found below:
Player Character
Room PNG
Screenshot of Character in Room

**A brief explanation of the functions in the current code**
*move() - if a certain arrow key is pressed, the character's X (playerX(1)) or Y (playerY(1)) position is changed to reflect the movement to the next square by an increment of 30px. Also moves the character within map() by 1.
*checkGrid() - checks to see if the cell the player wants his character to move into is empty (0) or full (1). Returns a value 1 if the character is able to move in or 0 if it is not.



Sprite Sheet (3x4 - one row for each direction)

His Imperial Majesty
18
Years of Service
User Offline
Joined: 19th Sep 2007
Location: Throne World of Korhal
Posted: 4th Sep 2010 20:14
Actually, never mind. I was able to figure it out. Sorry for jumping the gun, hah.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Sep 2010 22:34
Could you explain what you did to get it working (for future generations of forum searchers!)?

leo877
18
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 6th Sep 2010 01:10
wow your screen shoots reminds me of poekmon on gameboy


His Imperial Majesty
18
Years of Service
User Offline
Joined: 19th Sep 2007
Location: Throne World of Korhal
Posted: 6th Sep 2010 19:32
Yes, that was intentional. And I'll post my solution when I'm sure I've nailed it down. Still doing a bit of testing to completely flesh out the code.

Login to post a reply

Server time is: 2026-07-24 23:12:00
Your offset time is: 2026-07-24 23:12:00