How do i do that? Btw, i blitted my background before my while loop.
Printable View
How do i do that? Btw, i blitted my background before my while loop.
Look inside the header file for graphics.h.
That means is that it is blitting to one buffer only hence every time you flip the buffers, it go from the one that has the blitted the image and then the one without.
Blit it inside the loop.
You have to blit your image in the while loop, after a "clearScreen();". That will clear the screen every loop and update the images coordinates so it moves.
Edit: Uggh, I did it again. Damn slow typing.
Zitat:
Zitat von yaustar
Yea, i knew that was one way, but i have a problem with that:
Remember my file i/o functions?Code:if(strcmp (variable1,x) == 0)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bat, 0, 0);
}
if(strcmp (variable2,x) == 0)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bat2, 0, 0);
}
if(strcmp (variable3,x) == 0)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bat3, 0, 0);
}
if(strcmp (variable4,x) == 0)
{
blitAlphaImageToScreen(0, 0 , 480, 272, kill, 0, 0);
}
if(strcmp (variable5,x) == 0)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bubbles, 0, 0);
}
if(strcmp (variable6,x) == 0)
{
blitAlphaImageToScreen(0, 0 , 480, 272, penguin, 0, 0);
}
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
blitAlphaImageToScreen(0, 0, 35, 40, cursor, CursorXPosition, CursorYPosition);
sceDisplayWaitVblankStart();
flipScreen();
if (pad.Lx < 80) //left
CursorXPosition -= 3;
if (pad.Lx > 175) //right
CursorXPosition += 3;
if (pad.Ly > 175) //down
CursorYPosition += 3;
if (pad.Ly < 80) //up
CursorYPosition -= 3;
}
sceKernelSleepThread();
return 0;
}
That is easy to fix and if you know pointers like you claimed, you know how to solve it. It also looks like you don't understand program flow as well.
Hint: Temp image pointer.
You rule! Thanks for the hint. This really is easy. :Jump:Zitat:
Zitat von yaustar
Edit: It worked!
Also, would any body know how to simply fade in, and then out of an Image?Zitat:
Zitat von BlackShark
Sorry for this again, but i had to ask another question didn't I? Don't worry, this one shouldn't cause problems because this one should be simple. How do you print text using a custom font? Thanks.
about my "program" again, i still can't compail it..
i am fixen it now, ill post it later on..
edit: here it is:
Spoiler for main.c:
it's a miracle NO ERROR's @ all by just removing some code ;)
BS - Of an image? Or the background. If you need a specific image (not 480x272) you can simply use a background fading in/out but at specific coordinates, matching your image, and specific width/height,matching you image.
Xylem - flib i believe...
Now, my question.
Im now using C++ as my main language. Mainly for the shortcuts (booleans,namespaces,comp arison of2 strings via == operator, etc.). But now, im wanting to use the more object orientated side of C++. Now, ive barely touched on it, but here is a very simple class for a counter program (i believe theres a lesson as a counter, this is much like). Now, this class will include everything needed to work just by simplycalling members of it (nothing in main() wont be in this class)
Im going to write it up now. Id like someone experienced with OOP in C++ to look over it, and tell me whther or not it will work, and if it can be optimized somehow for efficiency (inline functions, etc.)
hmm no i've got a weird error , i see my menu and after 1 seconde it's gone
Ok.Zitat:
Zitat von SG57
yaustar would you please relook @ my progam the text isn't showing up, and I removed sceKernelExitGame(); and now my menu doesn't do anything :( home button is still working
I realy like if you could fix it :Jump:
Zitat:
Zitat von SG57
sorry, I meant background
Ok...
Heres my 'port' of Yeldarb's lesson 2 'counter' program, but to Object Orientated C++.
Tell me if this can be optimized at all and what you think :o
Code:#include <pspdebug.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <stdlib.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("OO C++ Counter", 0, 1, 1);
class Counter {
private: // these are only accessible via public/protected functions
int count;
SceCtrlData pad;
int GetCount() { return count; }
void IncrementBy(int value) { count+=value; }
// inlined Goodbye, is this bad as its a 3 liner ?
void Goodbye() { printf("Goodbye!"); sceKernelDelayThread(2000000); sceKernelExitGame(); }
// protected: accessible only by code in this source file, not entire program source?
public:
Counter(); // constructor
// no need for a deconstructor, int's are 'delete'd automatically
void Intro();
void Main();
void End();
};
Counter::Counter() { // constructor (would inlining this 2 liner be worse than this?)
pspDebugScreenInit();
pspDebugScreenClear();
count = 0;
}
void Counter::Intro() {
printf("Counter Program\n\n"
"Programmed using Object Orientated C++\n\n"
"Press any symbol button to begin");
for(;;) {
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons & (PSP_CTRL_CROSS|PSP_CTRL_SQUARE|PSP_CTRL_CIRCLE|PSP_CTRL_TRIANGLE)) {
break;
}
}
pspDebugScreenClear(); // clear residue for next place in program
}
void Counter::Main() {
printf("Count: %i\n\n"
"Press START to stop", GetCount());
for(;;) {
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons & (PSP_CTRL_START)) {
break;
}
pspDebugScreenSetXY(0,0);
printf("Count: %i\n\n"
"Press START to stop", GetCount());
IncrementBy(1);
}
pspDebugScreenClear(); // clear residue for next place in program
}
void Counter::End() {
printf("Final Count: %i\n\n"
"Press any symbol button to exit", GetCount());
for(;;) {
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons & (PSP_CTRL_CROSS|PSP_CTRL_SQUARE|PSP_CTRL_CIRCLE|PSP_CTRL_TRIANGLE)) {
break;
}
}
pspDebugScreenClear(); // clear residue for next place in program
Goodbye();
}
int main() {
Counter counter;
counter.Intro();
counter.Main();
counter.End();
return 0;
}
i havent looked over the entire code, but there is one thing:Zitat:
Zitat von SG57
you dont need a pad in the class. that would create a pad for each counter, which i doubt you want. ask yaustar for the rest ;)
1. Use initialisation lists in the constructor
2. You class breaks the rule of sole responsibility as shown in this link:Code:Counter::Counter() : counter(0)
{
//..
}
http://www.objectmentor.com/resources/articles/srp.pdf
Your counter class handles input, display AND the counter. It should only handle the counter. Imagine if you tried to use this class for a different role then displaying text such as timer for a gameplay entity such as a bomb? You would have to completely rewrite almost all the functions because of all the other junk that it also 'handles'. You should be able to take the class and use it from sub-system to sub-system with no change otherwise it is bad design.
Other useful links:
http://www.objectmentor.com/resources/articles/lsp.pdf
http://www.objectmentor.com/resources/articles/isp.pdf
http://www.objectmentor.com/resources/articles/dip.pdf
http://www.objectmentor.com/resources/articles/ocp.pdf
3. Goodbye should be a standard function. Inline functions should use the inline keyword:
4. GetCount and Goodbye should be a const function meaning that the data inside the class during this function is not changedCode:inline int GetCount() { return count; }
inline void IncrementBy(int value) { count+=value; }
Code:inline int GetCounter() const { return count; }
Im only creating one Counter in that entire program, as Counter IS the entier program. If i had actually been doing any other code in my main function, id set SceCtrlData pad; as a global.
and ya, that was my very first C++ OO program there :o It works, and is pretty readable Id say :violin:
yaustar - I understand that the Counter class should only consist of the counter, else it wouldnt be a counter class. But i just wanted to have nothing but function member calls in the main function from the Counter class. Also, are my comments correct? A couple had ? in them, signifying id like an answer :o
Also, what do you recommend i try to get abetter feel for OO C++ programming? I hear itll take years to really 'know' what C++ is, and that templates are what truly make C++ stand out. They take hours to learn, but days to master.... :violin:
Anyways, what do you recommend i do now? Should i make a basic pong game using OO C++, or what?
In which case, you are using classes incorrectly in principle. Give me a few minutes and I show you how I would write this.Zitat:
Zitat von SG57
yaustar - Please dont.... Atleast not to me yet. Id like to write something new and have you, or someone else, look over it and see how it is, showing im understanding what you say (not just nodding my head :P)
I chuck it in a spoiler in case I leave before you do. I would STRONGLY recommend reading those 5 articles on the principles of OO as well.
Spoiler for Dont read this:
-= Double Post =-
I would say no since a lot of them are pointless as it is obvoius from the code what it does. Read this article (and it's comments) for more insight:Zitat:
Zitat von SG57
http://cowboyprogramming.com/2007/02...umenting-code/
That is true, I only truely 'got it' last year.Zitat:
Also, what do you recommend i try to get abetter feel for OO C++ programming? I hear itll take years to really 'know' what C++ is, and that templates are what truly make C++ stand out. They take hours to learn, but days to master.... :violin:
A text adventure game would be good, pong would also be okay, if you want some structure you can try this assignment from gamedev:Zitat:
Anyways, what do you recommend i do now? Should i make a basic pong game using OO C++, or what?
Project 1
Project 2
Hey guys,
I was developing the G-Pack v.3, and i was just finishing up the configuration menu. However, the main problem i am facing is clicking and moving to next set of menu. I want to make a simple transition from the theme selection to cursor speed, and then to cpu speed. However, i don't think i am doing this right.....Anyways, if anyone could help me with these errors i am getting:
Btw, in my code, i didn't try to complete the rest (like putting the same functions for each entry). Try not to tell me how i can optimize it or if i am declaring the same functions, but only try to help me fix these errors. Here is the code:Code:main.c: In function 'configuration':
main.c(157) : warning: statement with no effect
main.c(158) : warning: statement with no effect
main.c(159) : warning: statement with no effect
main.c(160) : warning: statement with no effect
main.c(168) : warning: statement with no effect
main.c(169) : warning: statement with no effect
main.c(177) : warning: statement with no effect
main.c(178) : warning: statement with no effect
main.c(186) : warning: statement with no effect
main.c(187) : warning: statement with no effect
main.c(195) : warning: statement with no effect
main.c(196) : warning: statement with no effect
main.c(204) : warning: statement with no effect
main.c(205) : warning: statement with no effect
main.c(216) : warning: statement with no effect
main.c(217) : warning: statement with no effect
main.c: At top level:
main.c(630) : error: syntax error before '}' token
main.c(631) : warning: type defaults to 'int' in declaration of 'sceKernelSleepT
hread'
main.c(631) : warning: data definition has no type or storage class
main.c(632) : error: syntax error before 'return'
make: *** [main.o] Error 1
Code://G-Pack v.3 Shell
//Made by SuperbatXS
#include <stdio.h>
#include <stdlib.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <pspiofilemgr.h>
#include "graphics.h"
#include <pspcallbacks.h>
#include <string.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <psppower.h>
PSP_MODULE_INFO("G-Pack v.3", 0, 1, 1);
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
int ThemeSetting = 1;
int PointSetting = 1;
int CpuSetting = 1;
int pointer2()
{
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
if (pad.Lx < 80) //left
CursorXPosition -= 2;
if (pad.Lx > 175) //right
CursorXPosition += 2;
if (pad.Ly > 175) //down
CursorYPosition += 2;
if (pad.Ly < 80) //up
CursorYPosition -= 2;
if (pad.Buttons & PSP_CTRL_RTRIGGER){
configuration();
}
}
int pointer3()
{
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
if (pad.Lx < 80) //left
CursorXPosition -= 3;
if (pad.Lx > 175) //right
CursorXPosition += 3;
if (pad.Ly > 175) //down
CursorYPosition += 3;
if (pad.Ly < 80) //up
CursorYPosition -= 3;
if (pad.Buttons & PSP_CTRL_RTRIGGER){
configuration();
}
}
int pointer4()
{
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
if (pad.Lx < 80) //left
CursorXPosition -= 4;
if (pad.Lx > 175) //right
CursorXPosition += 4;
if (pad.Ly > 175) //down
CursorYPosition += 4;
if (pad.Ly < 80) //up
CursorYPosition -= 4;
if (pad.Buttons & PSP_CTRL_RTRIGGER){
configuration();
}
}
int pointer5()
{
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
if (pad.Lx < 80) //left
CursorXPosition -= 5;
if (pad.Lx > 175) //right
CursorXPosition += 5;
if (pad.Ly > 175) //down
CursorYPosition += 5;
if (pad.Ly < 80) //up
CursorYPosition -= 5;
if (pad.Buttons & PSP_CTRL_RTRIGGER){
configuration();
}
}
int configuration()
{
SceCtrlData pad, lastpad;
sceCtrlReadBufferPositive(&lastpad, 1);
FILE * theme;
FILE * pointer;
FILE * cpu;
Image* bat;
bat = loadImage("./images/superbat.png");
Image* bat2;
bat2 = loadImage("./images/superbatxs.png");
Image* bat3;
bat3 = loadImage("./images/superbatxs2.png");
Image* kill;
kill = loadImage("./images/kill.png");
Image* bubbles;
bubbles = loadImage("./images/bubbles.png");
Image* penguin;
penguin = loadImage("./images/sbg.png");
Color Color0 = RGB(259, 66, 0);
Color Color00 = RGB(0, 0, 255);
Color Color1 = RGB(0, 0, 0);
Color Color2 = RGB(0, 0, 0);
Color Color3 = RGB(0, 0, 0);
Color Color4 = RGB(0, 0, 0);
Color Color5 = RGB(0, 0, 0);
Color Color6 = RGB(0, 0, 0);
Color Color7 = RGB(0, 0, 0);
Color Color8 = RGB(0, 0, 0);
Color Color9 = RGB(0, 0, 0);
Color Color10 = RGB(0, 0, 0);
Color Color11 = RGB(0, 0, 0);
Color Color12 = RGB(0, 0, 0);
Color Color13 = RGB(0, 0, 0);
int ThemeMenu = 1;
int PointMenu = 0;
int CpuMenu = 0;
extern int ThemeSetting;
extern int PointSetting;
extern int CpuSetting;
while (1)
{
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons != lastpad.Buttons) {
lastpad = pad;
if (pad.Buttons & PSP_CTRL_CROSS)
{
if (ThemeMenu == 1)
{
if (ThemeSetting == 1)
{
char buffer[] = { '1' };
theme = fopen ( "./theme.txt" , "wb" );
fwrite (buffer , sizeof(buffer[0]) , sizeof(buffer) , theme );
fclose (theme);
ThemeMenu == 0;
ThemeSetting == 0;
PointMenu == 1;
PointSetting == 1;
}
if (ThemeSetting == 2)
{
char buffer2[] = { '2' };
theme = fopen ( "./theme.txt" , "wb" );
fwrite (buffer2 , sizeof(buffer2[0]) , sizeof(buffer2) , theme );
fclose (theme);
ThemeMenu == 0;
PointMenu == 1;
}
if (ThemeSetting == 3)
{
char buffer3[] = { '3' };
theme = fopen ( "./theme.txt" , "wb" );
fwrite (buffer3 , sizeof(buffer3[0]) , sizeof(buffer3) , theme );
fclose (theme);
ThemeMenu == 0;
PointMenu == 1;
}
if (ThemeSetting == 4)
{
char buffer4[] = { '4' };
theme = fopen ( "./theme.txt" , "wb" );
fwrite (buffer4 , sizeof(buffer4[0]) , sizeof(buffer4) , theme );
fclose (theme);
ThemeMenu == 0;
PointMenu == 1;
}
if (ThemeSetting == 5)
{
char buffer5[] = { '5' };
theme = fopen ( "./theme.txt" , "wb" );
fwrite (buffer5 , sizeof(buffer5[0]) , sizeof(buffer5) , theme );
fclose (theme);
ThemeMenu == 0;
PointMenu == 1;
}
if (ThemeSetting == 6)
{
char buffer6[] = { '6' };
theme = fopen ( "./theme.txt" , "wb" );
fwrite (buffer6 , sizeof(buffer6[0]) , sizeof(buffer6) , theme );
fclose (theme);
ThemeMenu == 0;
PointMenu == 1;
}
}
if (PointMenu == 1)
{
if (PointSetting == 1)
{
char buffer7[] = { '2' };
pointer = fopen ( "./pointer.txt" , "wb" );
fwrite (buffer7 , sizeof(buffer7[0]) , sizeof(buffer7) , pointer );
fclose (pointer);
PointMenu == 0;
CpuMenu == 1;
}
if (PointSetting == 2)
{
char buffer8[] = { '3' };
pointer = fopen ( "./pointer.txt" , "wb" );
fwrite (buffer8 , sizeof(buffer8[0]) , sizeof(buffer8) , pointer );
fclose (pointer);
}
if (ThemeSetting == 3)
{
char buffer9[] = { '4' };
pointer = fopen ( "./pointer.txt" , "wb" );
fwrite (buffer9 , sizeof(buffer9[0]) , sizeof(buffer9) , pointer );
fclose (pointer);
}
if (ThemeSetting == 4)
{
char buffer10[] = { '5' };
pointer = fopen ( "./pointer.txt" , "wb" );
fwrite (buffer10 , sizeof(buffer10[0]) , sizeof(buffer10) , pointer );
fclose (pointer);
}
}
if (CpuMenu == 1)
{
if (CpuSetting == 1)
{
char buffer11[] = { '1' };
cpu = fopen ( "./cpu.txt" , "wb" );
fwrite (buffer11 , sizeof(buffer11[0]) , sizeof(buffer11) , cpu );
fclose (cpu);
}
if (PointSetting == 2)
{
char buffer12[] = { '2' };
cpu = fopen ( "./cpu.txt" , "wb" );
fwrite (buffer12 , sizeof(buffer12[0]) , sizeof(buffer12) , cpu );
fclose (pointer);
}
if (ThemeSetting == 3)
{
char buffer13[] = { '3' };
cpu = fopen ( "./cpu.txt" , "wb" );
fwrite (buffer13 , sizeof(buffer13[0]) , sizeof(buffer13) , cpu );
fclose (cpu);
}
}
}
if (pad.Buttons & PSP_CTRL_UP)
{
if (ThemeMenu == 1)
{
ThemeSetting--;
if (ThemeSetting < 1)
ThemeSetting = 1;
PointSetting = 0;
CpuSetting = 0;
}
if (PointMenu == 1)
{
PointSetting--;
if (PointSetting < 1)
PointSetting = 1;
ThemeSetting = 0;
CpuSetting = 0;
}
if (CpuMenu == 1)
{
CpuSetting--;
if (CpuSetting < 1)
CpuSetting = 1;
ThemeSetting = 0;
PointSetting = 0;
}
}
if (pad.Buttons & PSP_CTRL_DOWN)
{
if (ThemeMenu == 1)
{
ThemeSetting++;
if (ThemeSetting > 6)
ThemeSetting = 6;
PointSetting = 0;
CpuSetting = 0;
}
if (PointMenu == 1)
{
PointSetting++;
if (PointSetting > 4)
PointSetting = 4;
ThemeSetting = 0;
CpuSetting = 0;
}
if (CpuMenu == 1)
{
CpuSetting++;
if (CpuSetting > 3)
CpuSetting = 3;
PointSetting = 0;
ThemeSetting = 0;
}
}
if (ThemeMenu == 1)
{
if (ThemeSetting == 1)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bat, 0, 0);
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(190, 190, 190);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (ThemeSetting == 2)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bat2, 0, 0);
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(190, 190, 190);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (ThemeSetting == 3)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bat3, 0, 0);
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(190, 190, 190);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (ThemeSetting == 4)
{
blitAlphaImageToScreen(0, 0 , 480, 272, kill, 0, 0);
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(190, 190, 190);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (ThemeSetting == 5)
{
blitAlphaImageToScreen(0, 0 , 480, 272, bubbles, 0, 0);
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(190, 190, 190);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (ThemeSetting == 6)
{
blitAlphaImageToScreen(0, 0 , 480, 272, penguin, 0, 0);
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(190, 190, 190);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
printTextScreen(170, 8, "Configuration File", Color0);
printTextScreen(10, 30, "Your Theme", Color00);
printTextScreen(170, 30, "Your Pointer Speed", Color00);
printTextScreen(330, 30, "CPU Speed", Color00);
printTextScreen(10, 50, "Bat Theme", Color1);
printTextScreen(10, 60, "Bat Theme 2", Color2);
printTextScreen(10, 70, "Bat Theme 3", Color3);
printTextScreen(10, 80, "Kill your Fear Theme", Color4);
printTextScreen(10, 90, "Bubbles", Color5);
printTextScreen(10, 100, "Penguin Theme", Color6);
printTextScreen(170, 50, "Slow", Color7);
printTextScreen(170, 60, "Medium", Color8);
printTextScreen(170, 70, "Fast", Color9);
printTextScreen(170, 80, "Very Fast", Color10);
printTextScreen(330, 50, "111MHz", Color11);
printTextScreen(330, 60, "222MHz (Default)", Color12);
printTextScreen(330, 70, "333Mhz", Color13);
}
sceDisplayWaitVblankStart();
flipScreen();
}
if (PointMenu == 1)
{
if (PointSetting == 1)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(190, 190, 190);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (PointSetting == 2)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(190, 190, 190);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (PointSetting == 3)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(190, 190, 190);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (ThemeSetting == 4)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(190, 190, 190);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
printTextScreen(170, 8, "Configuration File", Color0);
printTextScreen(10, 30, "Your Theme", Color00);
printTextScreen(170, 30, "Your Pointer Speed", Color00);
printTextScreen(330, 30, "CPU Speed", Color00);
printTextScreen(10, 50, "Bat Theme", Color1);
printTextScreen(10, 60, "Bat Theme 2", Color2);
printTextScreen(10, 70, "Bat Theme 3", Color3);
printTextScreen(10, 80, "Kill your Fear Theme", Color4);
printTextScreen(10, 90, "Bubbles", Color5);
printTextScreen(10, 100, "Penguin Theme", Color6);
printTextScreen(170, 50, "Slow", Color7);
printTextScreen(170, 60, "Medium", Color8);
printTextScreen(170, 70, "Fast", Color9);
printTextScreen(170, 80, "Very Fast", Color10);
printTextScreen(330, 50, "111MHz", Color11);
printTextScreen(330, 60, "222MHz (Default)", Color12);
printTextScreen(330, 70, "333Mhz", Color13);
}
}
if (CpuMenu == 1)
{
if (CpuSetting == 1)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(190, 190, 190);
Color12 = RGB(0, 0, 0);
Color13 = RGB(0, 0, 0);
}
else if (CpuSetting == 2)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(190, 190, 190);
Color13 = RGB(0, 0, 0);
}
else if (CpuSetting == 3)
{
Color0 = RGB(259, 66, 0);
Color00 = RGB(0, 0, 255);
Color1 = RGB(0, 0, 0);
Color2 = RGB(0, 0, 0);
Color3 = RGB(0, 0, 0);
Color4 = RGB(0, 0, 0);
Color5 = RGB(0, 0, 0);
Color6 = RGB(0, 0, 0);
Color7 = RGB(0, 0, 0);
Color8 = RGB(0, 0, 0);
Color9 = RGB(0, 0, 0);
Color10 = RGB(0, 0, 0);
Color11 = RGB(0, 0, 0);
Color12 = RGB(0, 0, 0);
Color13 = RGB(190, 190, 190);
}
printTextScreen(170, 8, "Configuration File", Color0);
printTextScreen(10, 30, "Your Theme", Color00);
printTextScreen(170, 30, "Your Pointer Speed", Color00);
printTextScreen(330, 30, "CPU Speed", Color00);
printTextScreen(10, 50, "Bat Theme", Color1);
printTextScreen(10, 60, "Bat Theme 2", Color2);
printTextScreen(10, 70, "Bat Theme 3", Color3);
printTextScreen(10, 80, "Kill your Fear Theme", Color4);
printTextScreen(10, 90, "Bubbles", Color5);
printTextScreen(10, 100, "Penguin Theme", Color6);
printTextScreen(170, 50, "Slow", Color7);
printTextScreen(170, 60, "Medium", Color8);
printTextScreen(170, 70, "Fast", Color9);
printTextScreen(170, 80, "Very Fast", Color10);
printTextScreen(330, 50, "111MHz", Color11);
printTextScreen(330, 60, "222MHz (Default)", Color12);
printTextScreen(330, 70, "333Mhz", Color13);
}
}
}
sceKernelSleepThread();
return 0;
}
int main () {
SetupCallbacks();
pspDebugScreenInit();
initGraphics();
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
Image* tback;
Image* cursor;
cursor = loadImage("./images/cursor.png");
char x[2];
char variable[2] = "0";
char variable1[2] = "1";
char variable2[2] = "2";
char variable3[2] = "3";
char variable4[2] = "4";
char variable5[2] = "5";
char variable6[2] = "6";
FILE *cpu;
if ((cpu = fopen("./cpu.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, cpu)] = 0;
fclose(cpu);
if(strcmp (variable1,x) == 0)
{
scePowerSetClockFrequency(111, 111, 111);
}
if(strcmp (variable2,x) == 0)
{
scePowerSetClockFrequency(222, 222, 111);
}
if(strcmp (variable3,x) == 0)
{
scePowerSetClockFrequency(333, 333, 166);
}
FILE *theme;
if ((theme = fopen("./theme.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, theme)] = 0;
fclose(theme);
if(strcmp (variable,x) == 0)
{
configuration();
}
if(strcmp (variable1,x) == 0)
{
tback = loadImage("./images/superbat.png");
}
if(strcmp (variable2,x) == 0)
{
tback = loadImage("./images/superbatxs.png");
}
if(strcmp (variable3,x) == 0)
{
tback = loadImage("./images/superbatxs2.png");
}
if(strcmp (variable4,x) == 0)
{
tback = loadImage("./images/kill.png");
}
if(strcmp (variable5,x) == 0)
{
tback = loadImage("./images/bubbles.png");
}
if(strcmp (variable6,x) == 0)
{
tback = loadImage("./images/sbg.png");
}
FILE *pointer;
if ((pointer = fopen("./pointer.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, pointer)] = 0;
fclose(pointer);
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
blitAlphaImageToScreen(0, 0 , 480, 272, tback, 0, 0);
blitAlphaImageToScreen(0, 0, 35, 40, cursor, CursorXPosition, CursorYPosition);
flipScreen();
if(strcmp (variable2,x) == 0)
{
pointer2();
}
if(strcmp (variable3,x) == 0)
{
pointer3();
}
if(strcmp (variable4,x) == 0)
{
pointer4();
}
if(strcmp (variable5,x) == 0)
{
pointer5();
}
}
sceKernelSleepThread();
return 0;
}
Those assignments are pretty in depth :-\ Itd be as if i were truly creating a game, not an example :(
Recommend anything else, or should i just make a pong game for the time being, and have you check over it? Im reading those PDFs as well.
-= Double Post =-
super - Im far too lazy to read, comprehend, and look for errors in your code, but I can say you really should use arrays (sorry if this is an optimization :P)
Yes, saying which lines the errors are on would help. I am not going to count to 165 lines.
Lol, i definitely should arrays. I will put those after someone helps me fix this. Also, didn't i already say which lines the errors are on (if you are asking for me to do it....)? So is anyone going to help (SG or Pspjunkie)? Just checking if you guys could help me (if you decide not to be lazy; no offense).
You did, but I don't know what line in the code it is. I'll do in myself, hold on.
Ok. Well i really hope you can fix this!Zitat:
Zitat von PSPJunkie_
You are making statements that make no sense.
You do
How does that make sense? You do it quite a lot of times, too.Code:if(ThemeMenu == 1)
{
ThemeMenu = 0;
}
Ok, what i am trying to do is move from the thememenu to the pointermenu. Now, if i put ThemeMenu = 0; , it will close the thememenu, and then after that, if i put PointerMenu = 1; and PointerSetting = 1; , it will take me to the PointerMenu, right?Zitat:
Zitat von PSPJunkie_
you seriously havent seen that before? ... (no comment)Zitat:
Zitat von PSPJunkie_
also, @superbaxts the first warning you got: statement with no effect, means this:
you probably have something like this on the error line:
there should only be one = in the block.Code:if (x == 10) {
y == 5;
}
Grim, I've seen it before, but scanning his code quickly, I don't think that's what he wanted. I could be wrong, I only briefly read your code.
As for the '==' and the '=', I thought it would usually give you a comparison error.
That's fine.Zitat:
Zitat von SG57
Super, that is the WORST menu code ever. Check out this example:
That's no the whole thing, but you should get the idea.Code:char Menuarray[10][30] = {
{"Menu Option 1"},
{"Menu Option 2"},
{"Menu Option 3"},
{"Menu Option 4"},
{"Menu Option 5"},
{"Menu Option 6"},
{"Menu Option 7"},
{"Menu Option 8"},
{"Menu Option 9"},
{"Menu Option 10"},
};
int print;
int select = 0;
for(;;) {
clearScreen(white)
for(print=0;print<10;print++) {
printTextCentered((print*10)+170,Menuarray[print],black);
}
printTextCentered((select*10+170,Menuarray[select],blue);
}
you can make it easier ,i am on ps3 now so cant fix it
Yea, i get the idea. Also, i got the menu code from here:Zitat:
Zitat von Access_Denied
http://www.psp-programming.com/forum...topic,359.html
Also, i tried to fix the == thing, and it worked! I removed the == and put = in the inside of the if loop.
arg i hate asking stupid basic c questions but i'm ganna ask anyways can you check strings?
for example:
Spoiler for code:
anyways trying to load an .x file(this code is only an example) and i need to check a string to find my streams position but it won't check for some reason
also:
i'm trying to read some numbers from a file
Spoiler for file snippet:
now then currently i've set up a way to get to:
Mesh SphereMesh {
and i'm trying to read the next number to an int
i thought hey lets use fscanf(pfile,&vertex_num) ;
did not work so tough hey lets try: fread(&vertex_num,2,1,pfi le);
i tried some other things but it won't read that number + i need to know how to check strings because they won't always say
Mesh SphereMesh {
and i just need to check for Mesh
anyways help would be appreciated and thanks in advance
edit: sry comp froze and it double posted
what are the psp's ad-hoc commands?
@slicer4ever: no, you can NEVER do that. Use strcmp api.
@Ha!-whatever: RTFM - http://psp.jim.sh/pspsdk-doc/pspnet__adhoc_8h.html
@adrahil ok thanks i'll try that i was beginning to think you couldn't