I was having a little trouble with loading sprites from my previous program (Tales of Symphonia the Homebrew (im trying to port it to C)) basically I want to the load attacking sprites without having to hold the required button combo until the attack finishes. Normally in lua i would do this:
function sonicthrustback()
counter:start()
current = counter:time()
if current >1050 then
status = "false"
playerimg = playerimgback
counter:reset()
end
if current >0 and current < 100 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust1.png")
end
if current >101 and current < 200 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust2.png")
end
if current >201 and current < 300 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust3.png")
end
if current >301 and current < 400 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust4.png")
end
if current >401 and current < 500 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust5.png")
end
if current >501 and current < 600 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust6.png")
end
if current >601 and current < 700 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust7.png")
end
if current >701 and current < 800 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust8.png")
end
if current >801 and current < 850 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust9.png")
end
if current >851 and current < 900 then
playerimg= Image.load("sprites/lloyd/Battle Sprites/Sonic Thrust/back/sonicthrust10.png")
end
end
is there a way to do this in C?(im not sure how one gets timers in C also)
EDIT:nvm i got it guess i got frustrated over nothing
Again, you are loading images in a place where you shouldn't. All images should be loaded before the game (or level if different for level) starts, then just use the pointers in the main code.
For your current level of C++ expertise, you'll probably get more help there. These really are basic questions you're asking.
"We are dreamers, shapers, singers, and makers. We study the mysteries of laser and circuit, crystal and scanner, holographic demons and invocations of equations. These are the tools we employ and we know... many things." -- Elric, B5
Art wrote:I hate to imagine what Mortal Kombat would be like if it loaded images only as requred.
Some 2D fighters for the PS1 actually DID load some images on the fly due to lack of memory. So certain transformations or attacks for certain characters would bring the game to a virtual halt while it loaded the images from CD.
yea normally i would load images and then call them in the main code however the person who made this code(SavageSnip3r (hes part of my team and a good friend)) was too lazy to make variables in the beginning and i just
copied his code.
snoopshady wrote:yea normally i would load images and then call them in the main code however the person who made this code(SavageSnip3r (hes part of my team and a good friend)) was too lazy to make variables in the beginning and i just copied his code.
That's not lazy programming, it's BAD programming. It creates a new image every time you switch images. Even on a PC, this would eventually crash when you exhausted the virtual memory. On the PSP, it'll blow up REAL quick since you don't have that much memory to play with.
That and the fact that the code has that ridiculous if/then method of choosing the image demonstrates that whoever wrote the code needs a few more lessons.