C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; If you mean cut a sprite sheet up then yes, you can... You use the offsets to do it... Image ...
-
05-30-2006, 03:01 PM #271words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
If you mean cut a sprite sheet up then yes, you can...
You use the offsets to do it...
Image dimensions of 100x100. Cut it in 2...
use the offsets for the first image ( 0, 50 )
Im jsut guessing on the use of the offsets, but i do know you use them to cut a sprite sheet up...

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
05-30-2006, 04:31 PM #272
Hi, I learn lua quit a wild ago but im more interested in C/C++ where can i start i mean which are the best tut to start whit.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
05-30-2006, 04:39 PM #273words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
ok... go to www.psp-programming.com thats where all the actual developers chill now a days
youll find tutorials to get you started, then examples and general help on how to code in C/C++... even LUA, this forum hasnt really any real hardcore LUA dev's that dont know about psp-programming.com ...
This forum is now more of a release thread...
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
05-31-2006, 05:47 AM #274Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes, of course you can do that. How stupid of me. Thanks anyway.
Zitat von SG57
Geändert von SodR (05-31-2006 um 10:54 AM Uhr)
-
05-31-2006, 06:22 AM #275words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Mental blocks are pretty common in programming i guess...

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-01-2006, 06:46 AM #276Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
When I try to animate a screen the second picture in the animation is displayed below the first one instead of on it.
This is the animation code:
This is the screenblit function. I borrowed it from FlashMod and added a function to it so you can choose where to display the image (this might be the problem?):Code:char intro_buffer[200]; Image* intro; sprintf(intro_buffer, "./Intro.png"); intro = loadImage(intro_buffer); char white_buffer[200]; Image* white; sprintf(white_buffer, "./white.png"); white = loadImage(white_buffer); screenblit(0, 0, 480, 272, white, 0, 0); screenblit(0, 0, 248, 59, intro, 120, 120); flipScreen(); sceKernelDelayThread(1000000); screenblit(0, 0, 480, 272, white, 0, 0); screenblit(0, 59, 248, 118, intro, 120, 120); flipScreen(); sceKernelDelayThread(1000000); screenblit(0, 0, 480, 272, white, 0, 0); screenblit(0, 118, 248, 177, intro, 120, 120); flipScreen(); sceKernelDelayThread(1000000); screenblit(0, 0, 480, 272, white, 0, 0); screenblit(0, 177, 248, 224, intro, 120, 120); flipScreen(); sceKernelDelayThread(1000000);
Thanks in advance.Code:void screenblit(int posx, int posy, int sizex, int sizey, Image* imagevar, int dx, int dy) { int x = 0; int y = 0; sceDisplayWaitVblankStart(); while (x < sizex) { while (y < sizey) { blitAlphaImageToScreen(posx ,posy ,sizex , sizey, imagevar, dx, dy); y += sizey; } x += sizex; y = 0; } }
btw. the sceKernelDelayThread() is just temporary used. I'm just using it with my testings.
-
06-01-2006, 07:18 AM #277words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
1. Put your images into an array for animation.
2. Dont flip the screen/draw buffer more then once (when animating)
3. Try this for a crappyly timed timer, and i havent tested it, its raw code i havent tested:
Try that or soimething allong the lines... oh and there blitting lower because you put eah image's Y co-ordinate higher then the other one, thus meanig it slower on the screen since the Y value it upside down.Code:Image* animation[2]; animation[0] = loadImage("./Intro.png"); animation[1] = loadImage("./white.png"); actualImage = animation[0]; int x = 0, fakeTimer = 0; while(1) { screenblit(all that jazz here, animation[x], all that jazz here); if (fakeTimer > 500 && fakeTimer<1000) x=1; else { x=0; } if (fakeTimer > 1000) { fakeTimer = 0; }
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-01-2006, 07:39 AM #278Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Thanks for the good example. But is there a way to do that with one "master" image ( that contains several sprites ) and ripping seperate sprites out of it??
Geändert von SodR (06-01-2006 um 11:32 AM Uhr)
-
06-02-2006, 05:21 AM #279Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Ok this sounds dumb but, is it:
??Code:pspWaitVblankStart();
I cant remember what it was lol.
-
06-02-2006, 05:29 AM #280Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It's
Zitat von kozine
Code:sceDisplayWaitVblankStart();
-
06-02-2006, 05:30 AM #281Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
ok thankyou
-
06-02-2006, 05:31 AM #282Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
No problem. This thread is about helping, right? :)
Zitat von kozine
-
06-02-2006, 05:40 AM #283Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
is it in mili seconds? If so, how many mili seconds to a second?Code:sceDisplayWaitVblankStart();
(Yes I know im dumb ;))
-
06-02-2006, 06:17 AM #284Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
1000mili secs = 1sec.
Zitat von kozine
Geändert von SodR (06-02-2006 um 06:41 AM Uhr)
-
06-02-2006, 06:30 AM #285QJ Gamer Platinum
- Registriert seit
- Dec 2005
- Ort
- h0000000rj
- Beiträge
- 12.867
- Points
- 57.528
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Um, no. 1000ms = 1s. mili = thousandth.
Zitat von SodR
[I fail @ life]
-
06-02-2006, 06:41 AM #286Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes, my mistake. What I said was in micro secs.
Zitat von FreePlay
Now it's edited =)
-
06-02-2006, 10:57 AM #287Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Does anyone have any tips of speeding up your program except changeing the cpus clock frequency?? (It mainly goes slow because of that it have many big images blited to the screen).
Geändert von SodR (06-03-2006 um 02:22 AM Uhr)
-
06-03-2006, 12:57 PM #288Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Ok guys im in need of help. Im trying to compile my program and it says:
main.c:391: error: syntax error at end of input
Line 391 is the very last line. Here is the last 4 lines (as I dont want people to see my code)
Code:// Exit Program while (1) { sceCtrlReadBufferPositive(&pad, 1); if (pad.Buttons & PSP_CTRL_CROSS) { MP3_Stop(); MP3_FreeTune(); sceKernelExitGame(); break; } } return 0; }
-
06-03-2006, 03:34 PM #289words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
kozine - Its not necessarly your last lines that is making the error... the Complier here is complaining you have left a '{' bracket open, or added an extra '}' somewhere, my advice is to get a good code editing software (UltaEdit or Dev-C++) and it will highlight the backets start and finish ones, that way you can find the problem... Hope this helps.

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-04-2006, 02:44 AM #290Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Thanks :) I got that sorted out and some other errors and it compiles now :) Thankyou SG57!
-
06-04-2006, 02:51 AM #291words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
:twisted:
Thats what this thread is for.
yes, i have some...
Zitat von SodR
1. Use external globals to help not make a brand new C source file just to have the same variable in 2 files
2. Use static variables instead of configuration files, that way theres no need to read/write from the mem stick for an always changing/same starting position variable...Geändert von SG57 (06-04-2006 um 02:55 AM Uhr)

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-05-2006, 11:55 AM #292Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
How do you use ascii with flib??
eg.doesn't work =S. Samstag told me that ascii was supported in flib. I get the "to many arguments to function" error...Code:text_to_screen(" %s\n", dirEntry->d_name, 350, 50);
-
06-05-2006, 03:01 PM #293words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
..SodR, flib is for displaying True Type Fonts (TTF), no?
The prototype for the text_to_screen doesnt support optional parameters, there for you must feed the diretory names and the '\n' character into na buffer before printing:
hope that helps...Code:char buffer[255]; struct dirent *dirEntry; sprintf(buffer, " %s\n", dirEntry->d_name); text_to_screen(buffer, 350, 50);]
Oh and if your going to be changing directories, make sure you 'sprintf' again, orelse the 'd_name' / file list, wont be updated to display the n ewe files in the new folder...
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-05-2006, 08:42 PM #294Developer

- Registriert seit
- Oct 2005
- Beiträge
- 408
- Points
- 7.058
- Level
- 55
- Downloads
- 0
- Uploads
- 0
You still seem to be confused about ascii. Your example shows printf escape codes, not ascii.
Zitat von SodR
This is all you need to do in this case.Code:text_to_screen(dirEntry->d_name, 350, 50);
-
06-05-2006, 08:47 PM #295words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Samstag - no, not neccesarly, that will print out the filenames, but no enter character, thus making it all one line...
(Unless the structure itself has a built in \n but i have tried it wihtout and it doesnt...)
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-05-2006, 08:53 PM #296Developer

- Registriert seit
- Oct 2005
- Beiträge
- 408
- Points
- 7.058
- Level
- 55
- Downloads
- 0
- Uploads
- 0
The variable dirEntry->d_name is a single filename, not a list of names.
Zitat von SG57
If you send \n to flib, you'll get a backslash and an "n".
-
06-05-2006, 09:08 PM #297words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Well i was assuming he was displaying the entire list of the filenames in the directory via a 'for' loop... meaning each time the loop repeated, it print the next filename, one line below...

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
06-06-2006, 02:44 AM #298Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I have never acctually used those kind of stuff very much but in my program I needed to use those functions. Thanks for informing me what it's called anyway. :)
Zitat von Samstag
Then what do you use for newline??
Zitat von Samstag
-
06-06-2006, 03:26 AM #299Developer

- Registriert seit
- Oct 2005
- Beiträge
- 408
- Points
- 7.058
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Change the Y value when you send the next line. You start with a Y value of 50 in your example. If you're using a 14 point font you could probably add 16 for each new line like this:
Zitat von SodR
I'll probably add simple support for newlines in a later version.Code:int y = 50; for(i = 0; i < NUMBER_OF_LINES; i++) { text_to_screen(line[i], 350, y); y += 16; }
-
06-06-2006, 04:04 AM #300Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
When I do like this I get a "makes pointer from integer without a cast" error. I can't figure out why. Do you know what to do to fix this?
Zitat von Samstag
btw. I assume that "i" is an integer with a value of 0 ( int i = 0; )


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum