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; Zitat von Insomniac197 Looks like it affects it to me mate. Follow the function through logically - it's pretty easy ...
-
09-28-2006, 04:35 AM #1021QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Yeah ok. I already wanted to edit my post. I used it but it turns my partially transparent PNGs into transparent squares :S. What I want to do is fade out the images of my mainmenu... .
Zitat von Insomniac197
-
09-28-2006, 05:45 AM #1022Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Faster way, draw a quad over the top that's black (or whatever color you want to fade out to) and covers the entire screen and then alter the alpha value of the color.
Something like this:
Where CSVertex is:Code:////////////////////////////////////////////////////////////////////// // Name: FadeScreen // Purpose: Fades the screen in/out (white) // Returns: NONE // Usage: Pass a value from 0.0f increasing to 1.0f to fade in, // 1.0f decreasing to 0.0f to fade out ////////////////////////////////////////////////////////////////////// void FadeScreen(const float FadeInAlphaValue) { guStart(); sceGuDisable(GU_TEXTURE_2D); CSVertex* vertices = (CSVertex*) sceGuGetMemory(2 * sizeof(CSVertex)); vertices[0].color = GU_COLOR(1.0f, 1.0f, 1.0f, FadeInAlphaValue); vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; vertices[1].color = GU_COLOR(1.0f, 1.0f, 1.0f, FadeInAlphaValue); vertices[1].x = 480; vertices[1].y = 272; vertices[1].z = 0; sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices); sceGuEnable(GU_TEXTURE_2D); sceGuFinish(); sceGuSync(0, 0); }
You can of course alter the function to take your own arguments - but this one is hard set to white.Code:typedef struct { unsigned int color; short x, y, z; } CSVertex;Geändert von Insomniac197 (09-28-2006 um 06:04 AM Uhr)

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-28-2006, 06:22 AM #1023AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Sometimes you have to change the alpha value without making a fade effect though...
Zitat von Insomniac197
I believe this should save the transparency that's already there:
Code:void SetAlphaImage(Image * image, unsigned int alpha) { int size; Color *databuf; if(!image->data) return; if(alpha>255) alpha = 255; if(alpha<0) alpha = 0; size = image->textureWidth * image->textureHeight; databuf = image->data; for(i = 0; i <= size; i++) { *databuf = (*databuf & 0x00ffffff) | ((A(*databuf)-(A(*databuf)-alpha))<<24); databuf++; } }
-
09-28-2006, 11:18 AM #1024QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Uhm, I compared this with the old version and I don't actually see a difference.
My recent Problem: (sorry for so many code)
Code:/* ------------------------------------- ARRAY PART 1 ------------------------------------- */ mainMenu[0].subMenu =(MenuItem *)malloc(5 * sizeof(MenuItem)); mainMenu[0].subMenu[0].iconHigh = loadImage("./img/mainmenu/s_eq_high.png"); mainMenu[0].subMenu[0].iconLow = loadImage("./img/mainmenu/s_eq_low.png"); mainMenu[0].subMenu[0].imgOffsetX = 5; mainMenu[0].subMenu[0].lblOffsetX = -3; sprintf(mainMenu[0].subMenu[0].label, "EQUALIZER"); mainMenu[0].subMenu[1].iconHigh = loadImage("./img/mainmenu/s_repeat_high.png"); mainMenu[0].subMenu[1].iconLow = loadImage("./img/mainmenu/s_repeat_low.png"); mainMenu[0].subMenu[1].imgOffsetX = 5; mainMenu[0].subMenu[1].lblOffsetX = 0; sprintf(mainMenu[0].subMenu[1].label, "REPEAT"); // [other menuitems] /* ------------------------------------- ARRAY PART 2 ------------------------------------- */ mainMenu[1].subMenu =(MenuItem *)malloc(1 * sizeof(MenuItem)); mainMenu[1].subMenu[0].iconHigh = loadImage("./img/mainmenu/gen_high.png"); mainMenu[1].subMenu[0].iconLow = loadImage("./img/mainmenu/gen_low.png"); mainMenu[1].subMenu[0].imgOffsetX = 5; mainMenu[1].subMenu[0].lblOffsetX = 0; sprintf(mainMenu[1].subMenu[0].label, "ARTISTS"); mainMenu[1].activeMenuItem = 0; /* ------------------------------------------------------------------------- */ /* Functions */ /* ------------------------------------------------------------------------- */ /* -------------------------------- Draw icon with text below it ------------------- */ void drawSubMenuItem(int selMM, int selSM, int x, int y, int high) { if(high == 1) { if(mainMenu[selMM].subMenu[selSM].iconHigh) { blitAlphaImageToScreen(0 ,0 ,32 , 32, mainMenu[selMM].subMenu[selSM].iconHigh, x+mainMenu[selMM].subMenu[selSM].imgOffsetX, y); } printTextScreen(x+mainMenu[selMM].subMenu[selSM].lblOffsetX, y+36, mainMenu[selMM].subMenu[selSM].label, highlightColor); } else if(high == 0) { if(mainMenu[selMM].subMenu[selSM].iconLow) { blitAlphaImageToScreen(0 ,0 ,32 , 32, mainMenu[selMM].subMenu[selSM].iconLow, x+mainMenu[selMM].subMenu[selSM].imgOffsetX, y); } printTextScreen(x+mainMenu[selMM].subMenu[selSM].lblOffsetX, y+36, mainMenu[selMM].subMenu[selSM].label, dimmedColor); } } /*-------------------- Draw vertical Menu of an XMB -------------------------------*/ void drawSubMenu(selComponent) { int i, y; for(i=0; i<=sizeof(mainMenu[selComponent].subMenu); i++) { if(i < mainMenu[selComponent].activeMenuItem) { y = 60 - (mainMenu[selComponent].activeMenuItem-i) * subDistance; drawSubMenuItem(selComponent, i, subOffsetX, y, 0); } else if(i == mainMenu[selComponent].activeMenuItem) { drawSubMenuItem(selComponent, i, subOffsetX, 100, 1); } else if(i > mainMenu[selComponent].activeMenuItem) { y = 100 + (i-mainMenu[selComponent].activeMenuItem) * subDistance;; drawSubMenuItem(selComponent, i, subOffsetX, y, 0); } } } // In my mainloop drawSubMenu(0); // using the first array works drawSubMenu(1); // Freezes the PSP on startup
When I call drawSubMenu with 0 as a parameter everything works fine. Using 1, which means using the 2nd part of the Array, the PSP freezes
-= Double Post =-
Added Comments.Geändert von Lukeson (09-28-2006 um 11:19 AM Uhr) Grund: Automerged Doublepost
-
09-29-2006, 12:16 AM #1025Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
when i try to use the danzeff OSK , it gives tons of erroros
here is my main.cCode:$ make kxploit psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai n.c In file included from danzeff.h:15, from main.c:5: pspctrl_emu.h:4:21: error: SDL/SDL.h: No such file or directory In file included from danzeff.h:15, from main.c:5: pspctrl_emu.h:23: error: nested redefinition of 'enum PspCtrlButtons' pspctrl_emu.h:23: error: redeclaration of 'enum PspCtrlButtons' pspctrl_emu.h:25: error: redeclaration of enumerator 'PSP_CTRL_SELECT' /usr/local/pspdev/psp/sdk/include/pspctrl.h:37: error: previous definition of 'P SP_CTRL_SELECT' was here pspctrl_emu.h:27: error: redeclaration of enumerator 'PSP_CTRL_START' /usr/local/pspdev/psp/sdk/include/pspctrl.h:39: error: previous definition of 'P SP_CTRL_START' was here pspctrl_emu.h:29: error: redeclaration of enumerator 'PSP_CTRL_UP' /usr/local/pspdev/psp/sdk/include/pspctrl.h:41: error: previous definition of 'P SP_CTRL_UP' was here pspctrl_emu.h:31: error: redeclaration of enumerator 'PSP_CTRL_RIGHT' /usr/local/pspdev/psp/sdk/include/pspctrl.h:43: error: previous definition of 'P SP_CTRL_RIGHT' was here pspctrl_emu.h:33: error: redeclaration of enumerator 'PSP_CTRL_DOWN' /usr/local/pspdev/psp/sdk/include/pspctrl.h:45: error: previous definition of 'P SP_CTRL_DOWN' was here pspctrl_emu.h:35: error: redeclaration of enumerator 'PSP_CTRL_LEFT' /usr/local/pspdev/psp/sdk/include/pspctrl.h:47: error: previous definition of 'P SP_CTRL_LEFT' was here pspctrl_emu.h:37: error: redeclaration of enumerator 'PSP_CTRL_LTRIGGER' /usr/local/pspdev/psp/sdk/include/pspctrl.h:49: error: previous definition of 'P SP_CTRL_LTRIGGER' was here pspctrl_emu.h:39: error: redeclaration of enumerator 'PSP_CTRL_RTRIGGER' /usr/local/pspdev/psp/sdk/include/pspctrl.h:51: error: previous definition of 'P SP_CTRL_RTRIGGER' was here pspctrl_emu.h:41: error: redeclaration of enumerator 'PSP_CTRL_TRIANGLE' /usr/local/pspdev/psp/sdk/include/pspctrl.h:53: error: previous definition of 'P SP_CTRL_TRIANGLE' was here pspctrl_emu.h:43: error: redeclaration of enumerator 'PSP_CTRL_CIRCLE' /usr/local/pspdev/psp/sdk/include/pspctrl.h:55: error: previous definition of 'P SP_CTRL_CIRCLE' was here pspctrl_emu.h:45: error: redeclaration of enumerator 'PSP_CTRL_CROSS' /usr/local/pspdev/psp/sdk/include/pspctrl.h:57: error: previous definition of 'P SP_CTRL_CROSS' was here pspctrl_emu.h:47: error: redeclaration of enumerator 'PSP_CTRL_SQUARE' /usr/local/pspdev/psp/sdk/include/pspctrl.h:59: error: previous definition of 'P SP_CTRL_SQUARE' was here pspctrl_emu.h:49: error: redeclaration of enumerator 'PSP_CTRL_HOME' /usr/local/pspdev/psp/sdk/include/pspctrl.h:61: error: previous definition of 'P SP_CTRL_HOME' was here pspctrl_emu.h:51: error: redeclaration of enumerator 'PSP_CTRL_HOLD' /usr/local/pspdev/psp/sdk/include/pspctrl.h:63: error: previous definition of 'P SP_CTRL_HOLD' was here pspctrl_emu.h:53: error: redeclaration of enumerator 'PSP_CTRL_NOTE' /usr/local/pspdev/psp/sdk/include/pspctrl.h:65: error: previous definition of 'P SP_CTRL_NOTE' was here pspctrl_emu.h:57: error: redefinition of 'struct SceCtrlData' pspctrl_emu.h:68: error: redefinition of typedef 'SceCtrlData' /usr/local/pspdev/psp/sdk/include/pspctrl.h:103: error: previous declaration of 'SceCtrlData' was here pspctrl_emu.h:70: error: syntax error before '*' token In file included from main.c:5: danzeff.h:58:27: error: SDL/SDL_image.h: No such file or directory In file included from main.c:5: danzeff.h:60: error: syntax error before '*' token
en here is the makefileCode:#include <math.h>//rekenmachine #include <pspkernel.h> #include <pspdebug.h> #include <pspctrl.h>//controls #include "danzeff.h" #define printf pspDebugScreenPrintf PSP_MODULE_INFO("calculator",0,0,1); /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } int y = 0; int x =0; int input; void vermenigvuldigen(); void delen (); void optellen(); void aftrekken(); SceCtrlData pad; int main() { pspDebugScreenInit(); SetupCallbacks(); menu(); } inline void menu() { danzeff_load(); danzeff_render(); while(1){ sceCtrlReadBufferPositive(&pad,1); if(pad.Buttons & PSP_CTRL_START){ break; } } printf( " ______ _______ _ ______ \n"); printf( " | ____| | ___ | | | | ____| v0.01 Beta test \n"); printf( " | | | | | | | | | | by roel \n"); printf( " | |____ | --- | | |____ | |____ (HALLO007)\n"); printf( " |______| |__| |__| |______| |______| -=[RP]=- Productions \n\n\n"); printf("druk start om het keyboard te openen\n"); printf("1.vermenigvuldig\n"); printf("2.delen\n"); printf("3.optellen\n"); printf("4.aftrekken\n"); printf("selectie: %d" , input); printf("druk op [X] om de selectie te activeren"); while(1){ sceCtrlReadBufferPositive(&pad,1); if(pad.Buttons & PSP_CTRL_CROSS) { switch (input) { case 1: printf("test"); case 2: printf("test"); case 3: printf("test"); case 4: printf("test"); default: printf("error , probeer opnieuw"); menu(); } } } } inline void vermenigvuldigen () { pspDebugScreenClear();//clear de screen printf( " ______ _______ _ ______ \n"); printf( " | ____| | ___ | | | | ____| v0.01 Beta test \n"); printf( " | | | | | | | | | | by roel \n"); printf( " | |____ | --- | | |____ | |____ (HALLO007)\n"); printf( " |______| |__| |__| |______| |______| -=[RP]=- Productions \n"); printf("schrijf 2 getallen voor te vermenigvuldigen: \n"); printf("de waarde van het eerste getal : %d \n" , x); printf("druk[X] om te bevestigen\n"); while(1) { sceCtrlReadBufferPositive(&pad, 1); if (pad.Buttons & PSP_CTRL_CROSS) { printf("de waarde van het tweede getal : %d\n" , y); printf("druk [X] om te vermenigvuldigen\n"); } } }
[/code]Code:TARGET = calculator OBJS = main.o danzeff.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = calculator PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak
-
09-29-2006, 12:24 AM #1026Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
There's a readme that comes with danzeff OSK.
Read it.
You need to choose within danzeff whether to use GU or SDL.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-29-2006, 12:42 AM #1027Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
that's the point i dont understand the readme

i want the use the SDL_Joystick
but dont know how do change it
-
09-29-2006, 01:16 AM #1028Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
You need SDL installed to be able to use it...
I think the default for danzeff is SDL.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-29-2006, 05:51 AM #1029QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Problem solved
Zitat von Lukeson
-
09-29-2006, 05:53 AM #1030
Glad to hear it.
-
09-30-2006, 06:17 AM #1031QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
hay i was wondering if any one can help give me a code to check if a file exists then load it and have it tell me when it exits i look all over but i couldnt find any.
-
09-30-2006, 06:22 AM #1032Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
could just do:
Zitat von zmathue
file = fopen("./file.txt", "r");
if(file==NULL) { //file dosn't exist
} else {
//file exists
}
-
09-30-2006, 06:24 AM #1033AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
To check if a file exists you simply do
Zitat von zmathue
Not sure what you mean by the "exit" part though.Code://Open the file, change file path to the file you wish to check. rb indicates that it opens in read-binary mode. FILE * file = fopen("file path", "rb"); //If file==0 (same as !file) the file doesn't exist if(!file) { printf("file does not exist"); return 0; } //Close the open file fclose(file); return 1;
-
09-30-2006, 06:29 AM #1034QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
what i ment was when the app i loaded exits out of itself that i want it to tell my program that it exited and do something
-
09-30-2006, 06:33 AM #1035AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Oh, in that case. Just add this to your main (preferbly where you intialize the app)
And then add thisCode:int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid);
Code:/* Exit callback */ int exit_callback() { //Add stuff here sceKernelExitGame(); return 0; }
-
09-30-2006, 06:43 AM #1036QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
actualy I mean when i load the app that i checked if it exists when that app exits then i want it to do something.
Zitat von homer
Geändert von zmathue (09-30-2006 um 06:56 AM Uhr) Grund: Cuz i did
-
10-01-2006, 05:55 AM #1037<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
whats the screen brightness button code
(the one beside note)
-
10-01-2006, 06:00 AM #1038OMFG

- Registriert seit
- Jul 2005
- Ort
- Toronto
- Beiträge
- 2.814
- Points
- 19.453
- Level
- 88
- Downloads
- 0
- Uploads
- 0
PSP_CTRL_SCREEN = 0x400000
Zitat von Sousanator
It can only be read in kernel mode.
-
10-01-2006, 06:32 AM #1039QJ Gamer Green
- Registriert seit
- Jun 2006
- Ort
- London
- Beiträge
- 645
- Points
- 6.256
- Level
- 51
- Downloads
- 0
- Uploads
- 0
Can it be modified?
[b][center]
[URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]
[url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]
-
10-01-2006, 06:34 AM #1040Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Nutterbutter
that depends.. what do you mean by modified?? like changing the value?? i guess.. ask slasher. ;)--------------------------------------------------------------------------------------
-
10-01-2006, 08:45 AM #1041<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
thanks,,
Zitat von Slasher
and is there some way to control the screen brightness?
(without touching the button, or disabling the button to change brightness)
-
10-02-2006, 08:41 AM #1042QJ Gamer Blue
- Registriert seit
- Mar 2006
- Ort
- France
- Beiträge
- 239
- Points
- 7.538
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Well I installed CYGWIN & PSPTOOLCHAIN, and I tried to compil an EBOOT and her's what it said :

Note : if i "make" again then, it creates an eboot that shuts off the PSP :S
-
10-02-2006, 10:52 AM #1043Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Does there exist a cos^-1 function?
try adding the
Zitat von Maxime
PSP_MODULE_INFO("hellowor ld", 0, 1, 1); line.
-
10-02-2006, 11:00 AM #1044Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
How about acos?
Zitat von waterbottle
EDIT: Congrats on making the 1,000,000th post. :)
-
10-02-2006, 11:21 AM #1045AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
How about
Zitat von waterbottle
pow(cos(), -1);
?
-
10-02-2006, 11:30 AM #1046Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
when i tried to make a variabel x , one bigger when you pressed the up button
it goes many numbers up i did this
(note : ofcourse this code wont work , lol)
if (up pressed)
x++
how do you do that it only goes one number up if you pressed the up button , and if you press the up button again it goes another number up
for example
x=1
up button pressed
x=2
up button presse
x=3
now it does this
up button pressed
x=1
x=2
x=3
x=4
x=5
....
thnx in advance
-
10-02-2006, 11:38 AM #1047Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
basically you want to check if the button was pressed last frame. this should work:
Zitat von hallo007
Code:// Put this outside of your loop // char upPressed = "false" // This initializes "upPressed" // // Put this in you main loop // if (up pressed) { // If you press up // if (upPressed == "false") { x++; } upPressed = "true" } else { upPressed = "false" }--------------------------------------------------------------------------------------
-
10-02-2006, 11:47 AM #1048Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
i will repeat it and now write the code ;)
when i tried to make a variabel x , one bigger when you pressed the up button
it goes many numbers up i did this
if(pad.Buttons & PSP_CTRL_UP) {
x++;
}
how do you do that it only goes one number up if you pressed the up button , and if you press the up button again it goes another number up
for example
x=1
up button pressed
x=2
up button presse
x=3
now it does this
up button pressed
x=1
x=2
x=3
x=4
x=5
....
thnx in advance
-= Double Post =-
so if you hold the up button ,it does only one time something
and that's x+1
now if you hold it , it stayes x+1,x+1,...Geändert von hallo007 (10-02-2006 um 11:47 AM Uhr) Grund: Automerged Doublepost
-
10-02-2006, 11:50 AM #1049Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
have you even TRIED my code?? just try it, it WILL work.
Zitat von hallo007
--------------------------------------------------------------------------------------
-
10-02-2006, 11:54 AM #1050Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
oke thnx;)
i will tried ,but first get some sleep;)


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