Moving Sprite Demo

PSPYeldarb has just provided some source code he has developed for the PSP. It’s an arrow that one can move around the screen. This requires an external image, in this case ‘arrow.png’ and depends on the graphics.h header.

This program loads in a “sprite” (in this case it’s just a simple arrow icon). I have made four frames of the sprite and put them all on the same image. The code splits these into separate “images” in an array. Basically, it’s a way to get frames out of a single image (that way you don’t have to mess with a ton of different image files).

The different frames in this case are different rotations of the arrow sprite. You can control the arrow with the arrow buttons. Turn the trail of arrows on and off with the triangle button. Left trigger slows down the speed, right trigger slows it up. “X” is the gas button.

Basically, by studying this source code (which, admittedly, is very simple) you will know how to make a sprite travel around the screen (bound by the edges), how to erase the image on subsequent frames, how to control speed, and how to pseudo-rotate a sprite.

Download: [Moving Sprite Source]

PSPYeldarb has just provided some source code he has developed for the PSP. It’s an arrow that one can move around the screen. This requires an external image, in this case ‘arrow.png’ and depends on the graphics.h header.

This program loads in a “sprite” (in this case it’s just a simple arrow icon). I have made four frames of the sprite and put them all on the same image. The code splits these into separate “images” in an array. Basically, it’s a way to get frames out of a single image (that way you don’t have to mess with a ton of different image files).

The different frames in this case are different rotations of the arrow sprite. You can control the arrow with the arrow buttons. Turn the trail of arrows on and off with the triangle button. Left trigger slows down the speed, right trigger slows it up. “X” is the gas button.

Basically, by studying this source code (which, admittedly, is very simple) you will know how to make a sprite travel around the screen (bound by the edges), how to erase the image on subsequent frames, how to control speed, and how to pseudo-rotate a sprite.

Download: [Moving Sprite Source]

Add a Comment

Your email address will not be published. Required fields are marked *