forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Some simple questions

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Tue Jan 31, 2006 11:20 pm    Post subject: Some simple questions Reply with quote

Hi folks,

First of all i have a visual basic background so my C can be bad.
i have some problems getting my thingy to work. First off topic, my game always crashes after a certain frames. Why is this? i mean i had it some other time and then i looked like a variable i declared everytime the function was called took in all space. Is this right that every time i declare the same int i that it takes everytime some memory?

anyhow i have this problem with connection a directory name to a string. I tried alot but just won't work:

here is what i have tried:

Code:

sprintf(buffer, "Themes/ dirEntry->d_name /Block1.png");
Blocks[1] = loadImage(buffer);

sprintf(buffer, "Themes/" + dirEntry->d_name + "/Block1.png");
Blocks[1] = loadImage(buffer);

sprintf(buffer, "Themes/" & dirEntry->d_name & "/Block1.png");
Blocks[1] = loadImage(buffer);


the dir-entry->d_name is a char variable so if someone can help me out here :)

the last question is something that has to do with displaying pictures. I use the png library and i use the graphics.h files distributed with the tutorial of Yeldarb. I load up the picture and displays them this works fine. However i want to change the picture so i try to free the memory and then reload it but everytime it freezes up.

P.S. is there something to debug psp software? like a windows prog that can run the program and shows where it halts (so i can see better what is the problem.)

greets ghoti
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Dr. Vegetable



Joined: 14 Nov 2005
Posts: 171
Location: Boston, Massachusetts

PostPosted: Tue Jan 31, 2006 11:54 pm    Post subject: Reply with quote

Try this:

Code:
sprintf(buffer, "Themes/%s/Block1.png",  dirEntry->d_name);
Blocks[1] = loadImage(buffer);


The sprintf() function takes a buffer and a format string, followed by zero or more other parameters. Every '%' in the format string tells sprintf() to replace that portion of the format string with the next parameter in sequence. In this case, "%s" tells sprintf() that a "string" should be formatted, so "%s" gets replaced with the directory name. The formatting works the same as for the printf() function.

Hope this helps!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Wed Feb 01, 2006 12:22 am    Post subject: Reply with quote

Here's more reference on the format string functions and how they work:

http://www.cplusplus.com/ref/cstdio/printf.html

It may look very complicated first, esp if you come from a language like basic, pascal (like I do) or java, but it's rather simple actually and is much mor flexible than the string concatenation of the other languages, once you get used to it. :)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group