Seite 183 von 340 ErsteErste ... 83 133 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 233 283 ... LetzteLetzte
Zeige Ergebnis 5.461 bis 5.490 von 10174

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; Well, what are the errors?...

  
  1. #5461
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Well, what are the errors?


    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  2. #5462
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Well, what are the errors?
    Code:
    $ make
    psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=
    150   -c -o main.o main.c
    main.c: In function 'main':
    main.c:31: error: syntax error before '&' token
    main.c: At top level:
    main.c:57: error: syntax error before '&' token
    main.c: In function 'FPS':
    main.c:59: error: 'fps' undeclared (first use in this function)
    main.c:59: error: (Each undeclared identifier is reported only once
    main.c:59: error: for each function it appears in.)
    main.c:60: error: 'fpsTickNow' undeclared (first use in this function)
    main.c:62: error: 'fpsTickLast' undeclared (first use in this function)
    main.c:62: error: 'tickResolution' undeclared (first use in this function)
    main.c:65: error: 'fpsDisplay' undeclared (first use in this function)
    make: *** [main.o] Error 1
    Below is the whole code for the project (Yes i know it does pretty much sod all right now but I just need to set the basics up and get everything moving).

    Code:
    #include <malloc.h>						//For memalign()
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspdebug.h>
    #include <stdio.h>
    #include <pspcallbacks.h>
    #include <pspgu.h>
    #include <pspgum.h>
    #include <psprtc.h>						// for the timer/fps functions
    #include "graphics.h"
    
    #define BUF_WIDTH  (512)
    #define SCR_WIDTH  (480)
    #define SCR_HEIGHT (272)
    
    PSP_MODULE_INFO("Breakout", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
    
    void *fbp0;
    
    int main(int argc, char **argv)
    {
    	int fps = 0;							// for calculating the frames per second
    	char fpsDisplay[100];
    	u32 tickResolution;
    	u64 fpsTickNow;
    	u64 fpsTickLast;
    
    	void FPS(int&, char*, u32&, u64&, u64&);										// Display Frames Per Second 	
    	initGraphics();
    
    	pspDebugScreenInit();
    	SetupCallbacks();
    
    	sceRtcGetCurrentTick( &fpsTickLast );
    	tickResolution = sceRtcGetTickResolution();
     
    	while(1)
    	{
    
    		FPS(fps, fpsDisplay, tickResolution, fpsTickNow, fpsTickLast);
    		flipScreen();
        }
    
    	sceGuTerm();			// Terminating the Graphics System
    	sceKernelExitGame();	// Quits Application
    	return 0;
    }
    
    void mainMenu()
    {
    	
    }
    
    void FPS(int& fps, char* fpsDisplay[], u32& tickResolution, u64& fpsTickNow, u64& fpsTickLast)
    {
    	fps++;
    	sceRtcGetCurrentTick( &fpsTickNow );
    	
    	if(((fpsTickNow - fpsTickLast) / ((float)tickResolution)) >= 1.0f)
    	{
    		fpsTickLast = fpsTickNow;
    		sprintf( fpsDisplay, "FPS: %d", fps );
    		fps = 0;
    	}
    	pspDebugScreenSetOffset( (int)fbp0 );
    	pspDebugScreenSetXY( 0, 0 );
    	pspDebugScreenPrintf( fpsDisplay );
     
    }
    Code in Graphics.h is optimised, contains a few extra functions and mostly uses the GU, but that doesn't seem to be the error, and i've used this code plently of times before....

  3. #5463
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You've got a forward declaration in the middle of a function. You can't do that. Move it above the main function.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  4. #5464
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    You've got a forward declaration in the middle of a function. You can't do that. Move it above the main function.
    I'm not with ya. Whats a forward declaration ?

  5. #5465
    QJ Gamer Platinum
    Points: 57.528, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    h0000000rj
    Beiträge
    12.867
    Points
    57.528
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    You've got this in the middle of your main function:
    Code:
    void FPS(int&, char*, u32&, u64&, u64&);
    Move it *outside* of the main function (above it).
    [I fail @ life]

  6. #5466
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FreePlay
    You've got this in the middle of your main function:
    Code:
    void FPS(int&, char*, u32&, u64&, u64&);
    Move it *outside* of the main function (above it).
    why would that matter?

    I'd got a program with around 10 Function Delcarations in the main() function..
    I Don't get it... I was always told put function declarations before you use the function, not in global territory.

    EDIT - I Moved it, same error..

  7. #5467
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Yes, before you use the function...but it has to be global.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  8. #5468
    QJ Gamer Green
    Points: 5.795, Level: 49
    Level completed: 23%, Points required for next Level: 155
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Cape Town, South Africa
    Beiträge
    714
    Points
    5.795
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    I need to know this. I have an array on the heap like this:

    Code:
    // (Throwable is a struct)
    int numThrowables ;
    Throwable* throwables ;
    // ...
    numThrowables = /* some value unknown at compile time */
    throwables = malloc(sizeof(Throwable) * numThrowables) ;
    How do I free this array? Will simply calling free(throwables) work or do I have to do something else?

  9. #5469
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    im making a snake game, i can get a snake that is 5 blocks long to move around the screen using the directional buttons. Ive tried to make it add blocks to the snake but i cant seem to make it work correctly. Im not going to post the code, because its not the codr that is the problem. Here's what the situation is:

    The snake starts like this: (H = head, b# = body part)

    Code:
    b4 b3 b2 b1 H
    then when it moves the head moves forward and b4 goes to the old position of the head:

    Code:
    b3 b2 b1 b4 H
    The body parts are an array of structures that hold the X and Y coords of themsleves. The snake length variable holds the length of the snake and during run time, each part of the snake is blitted to the screen according to the co-ordinates it hold. Now, heres where i ran into the problem. When i add a new part of the body, it has to insert it at the end of the array, meaning there is only one position that it will add the block instantly. For example: (F = Food)

    Code:
    b2 b1 b4 b3 H F  ->  b2 [b1b5] b4 b3 H
    The new block overlaps the old one and the snake only appears longer when the snake is at is original state:

    Code:
    b5 b4 b3 b2 b1 H
    So, there you have it, does anyone know the solution to this problem or have made a snake game themselves?

    PS: if you really want to look at the code, here it is:

    Spoiler for Code:
    Code:
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <png.h>
    #include <stdio.h>
    #include "graphics.h"
    
    PSP_MODULE_INFO( "Snake", 0, 1, 1 );
    typedef enum _bool { false, true } bool;
    
    /* 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;
    }
    
    typedef struct
    {
            int x;
            int y;
    } BodyPart;
    
    void DrawBody();
    void InitBody();
    
    Image* Head;
    Image* Back;
    Image* Body;
    
    BodyPart bodyParts[30];
    
    enum{ DIR_UP, DIR_LEFT, DIR_RIGHT, DIR_DOWN };
    
    int headX, headY, oldX, oldY;
    int moveCount;
    int dir;
    int snakeLength, oldLength;
    int i;
    int back;
    
    bool exitFlag;
    bool newPart;
    
    SceCtrlData pad;
    
    int main()
    {
        SetupCallbacks();
        initGraphics();
        
        headX = 80;
        headY = 80;
        
        moveCount = 0;
        
        snakeLength = 3;
        back = snakeLength;
        
        Head = loadImage( "body.png" );
        Back = loadImage( "back.png" );
        Body = Head;
        
        dir = DIR_RIGHT;
        
        exitFlag = false;
        newPart = false;
        
        InitBody();
        
        while( exitFlag == false )
        {
               clearScreen(0);
               sceCtrlReadBufferPositive(&pad, 1);
               
               blitAlphaImageToScreen( 0, 0, 480, 272, Back, 0, 0 );
               blitAlphaImageToScreen( 0, 0, 16, 16, Head, headX, headY );
               DrawBody();
               
               if( pad.Buttons & PSP_CTRL_UP )
                   dir = DIR_UP;
               
               if( pad.Buttons & PSP_CTRL_DOWN )
                   dir = DIR_DOWN;
               
               if( pad.Buttons & PSP_CTRL_LEFT )
                   dir = DIR_LEFT;
               
               if( pad.Buttons & PSP_CTRL_RIGHT )
                   dir = DIR_RIGHT;
               
               if( pad.Buttons & PSP_CTRL_START )
                   exitFlag = true;
               
               if( moveCount >= 30 )
               {
                   oldX = headX;
                   oldY = headY;
                   
                   if( pad.Buttons & PSP_CTRL_CROSS )
                   {
                        newPart = true;
                   }
                   
                   switch( dir )
                   {
                           case DIR_UP:
                                headY -= 16;
                                break;
                           
                           case DIR_DOWN:
                                headY += 16;
                                break;
                           
                           case DIR_LEFT:
                                headX -= 16;
                                break;
                           
                           case DIR_RIGHT:
                                headX += 16;
                                break;
                           
                           default:
                                break;
                   }
                   moveCount = 0;
                   
                   if( newPart == true )
                   {
                       oldLength = snakeLength;
                       snakeLength++;
                       bodyParts[snakeLength].x = bodyParts[oldLength].x;
                       bodyParts[snakeLength].y = bodyParts[oldLength].y;
                       newPart = false;
                   }
                   
                   bodyParts[back].x = oldX;
                   bodyParts[back].y = oldY;
                   if( back == 0 )
                   {
                       back = snakeLength;
                   }   
                   else
                   {
                       back--;
                   }
               }
               
               flipScreen();
               moveCount++;
        }
        sceKernelExitGame();
        return 0;
    }
    
    void InitBody()
    {
         bodyParts[0].x = 64;
         bodyParts[0].y = 80;
         
         bodyParts[1].x = 48;
         bodyParts[1].y = 80;
         
         bodyParts[2].x = 32;
         bodyParts[2].y = 80;
         
         bodyParts[3].x = 16;
         bodyParts[3].y = 80;
    }
    
    void DrawBody()
    {
         for( i = 0; i < (snakeLength+1); i++ )
         {
              blitAlphaImageToScreen( 0, 0, 16, 16, Body, bodyParts[i].x, bodyParts[i].y );
         }
    }
    ...Just Returned To The Scene...

  10. #5470
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Yes, before you use the function...but it has to be global.
    Well, I changed it, and same error. Function Declarations do not have to be global either.

  11. #5471
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von coolguy5678
    I need to know this. I have an array on the heap like this:

    Code:
    // (throwable is a struct)
    int numThrowables ;
    Throwable* throwables ;
    // ...
    numThrowables = /* some value unknown at compile time */
    throwables = malloc(sizeof(Throwable) * numThrowables) ;
    How do I free this array? Will simply calling free(throwables) work or do I have to do something else?
    free is how you do it. The size allocated with malloc is know to the free function.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  12. #5472
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von coolguy5678
    I need to know this. I have an array on the heap like this:

    Code:
    // (Throwable is a struct)
    int numThrowables ;
    Throwable* throwables ;
    // ...
    numThrowables = /* some value unknown at compile time */
    throwables = malloc(sizeof(Throwable) * numThrowables) ;
    How do I free this array? Will simply calling free(throwables) work or do I have to do something else?
    Yeah, im sure free() will work.
    ...Just Returned To The Scene...

  13. #5473
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von MiG
    Well, I changed it, and same error. Function Declarations do not have to be global either.
    Yeah, not in the case of private member functions. But that's only in C++.
    AFAIK, in C, all functions are global scope.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  14. #5474
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    ok question why is atan2 messing up my other units?

    ok here's whats hapeening:

    Spoiler for code:

    Spoiler for draw scene function:

    Code:
    void drawscene(void){
         for(int i=0;i<unit_num;i++){
              if(unit[i][3]==1){
                   drone->x = unit[i][0];
                   drone->y = unit[i][1];
                   drone->angle = unit[i][2];
                   if(selected_unit==i){
                        oslDrawRect(unit[i][0]-drone->sizeX/2,unit[i][1]-drone->sizeY/2,unit[i][0]+drone->sizeX/2,unit[i][1]+drone->sizeY/2,RGBA(0,255,0,255));
                   }
                   turrent_level_one->x = unit[i][0] + (int)oslSin((int)unit[i][2],23/2);
                   turrent_level_one->y = unit[i][1] - (int)oslCos((int)unit[i][2],22/2);
                   oslDrawImage(drone);
                   oslDrawImage(turrent_level_one);
              }
              movement(i);
              if(osl_keys->pressed.cross){
                   select_unit(i);
              }
         }
         if(selected_unit!=-1){
              if(osl_keys->pressed.circle){
                  selected_unit=-1;
              }
         }
         if(osl_keys->pressed.triangle){
              build_drone();
         }
         cursor->x = cx;
         cursor->y = cy;
         oslDrawImage(cursor);
         cursorf();
    }

    Spoiler for movement function:

    Code:
    void movement(int check_unit){
         if(selected_unit != -1){
              if(osl_keys->pressed.cross){
                   unit[selected_unit][4] = cx+mapx;
                   unit[selected_unit][5] = cy+mapy;
                   //unit[selected_unit][8] = atan2(unit[selected_unit][0]-unit[selected_unit][4],unit[selected_unit][1]-unit[selected_unit][5])*(180/PI)*-1;
              }
         }
         if((!(unit[check_unit][0]>unit[check_unit][4]-10 && unit[check_unit][0]<unit[check_unit][4]+10)) || (!(unit[check_unit][1]>unit[check_unit][5]-10 && unit[check_unit][1]<unit[check_unit][5]+10))){
              //unit[check_unit][8] = atan2(unit[check_unit][0]-unit[check_unit][4],unit[check_unit][1]-unit[check_unit][5])*(180/PI)*-1;
              if(unit[check_unit][2]>=unit[check_unit][8]){
                   unit[check_unit][2]-=unit[check_unit][7];
              }else if(unit[check_unit][2]<unit[check_unit][8]){
                   unit[check_unit][2]+=unit[check_unit][7];
              }
              unit[check_unit][0] += oslSin(unit[check_unit][2],unit[check_unit][6]);
              unit[check_unit][1] -= oslCos(unit[check_unit][2],unit[check_unit][6]);
         }
         oslSetTextColor(RGBA(0,0,255,255));
         oslSetBkColor(RGBA(0,0,0,0));
         oslPrintf_xy(0,10*check_unit,"x: %d",unit[check_unit][0]);
    }



    i determined it was the 2 atan2 commands which well screw up my units here's what i mean:

    i select a unit any unit who hasen't been looped though well just jump to random locations on the screen and i don't know why

    i hope i managed to get my problem across clearly and hope someone can help me
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  15. #5475
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    anyone wanna take a look at my problem on the previous page?
    ...Just Returned To The Scene...

  16. #5476
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Yeah, not in the case of private member functions. But that's only in C++.
    AFAIK, in C, all functions are global scope.
    Right, ok. I've only really studied C++ so thought it was the same for C. I've now switched to C++ for the main file and now get the original error i was getting, the undefinded reference.. blah blah.

  17. #5477
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    I checked, and the lines don't seem to match up with the errors they raise.

    But you still can't do what you did in C++. I say private members, and that isn't a member at all, nor where you're defining it would ever be a member.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  18. #5478
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    I checked, and the lines don't seem to match up with the errors they raise.

    But you still can't do what you did in C++. I say private members, and that isn't a member at all, nor where you're defining it would ever be a member.
    I've got a Full Pacman style game here written in C++ for the Console on the PC, and that compiles with function declerations just fine.

    I'm pretty sure you can or surely my code wouldn't work ?

    And I know, the errors just don't match up to the Code, it sucks.

  19. #5479
    QJ Gamer Platinum
    Points: 57.528, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    h0000000rj
    Beiträge
    12.867
    Points
    57.528
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von MiG
    I Don't get it... I was always told put function declarations before you use the function, not in global territory.
    I'm pretty sure you can't use & in a function param... what are you trying to do, get the address of the argument? If so, you have to use * instead, and use & on the value you pass *into* the function so you're passing its address.
    Zitat Zitat von MiG
    I've got a Full Pacman style game here written in C++ for the Console on the PC, and that compiles with function declerations just fine.

    I'm pretty sure you can or surely my code wouldn't work ?
    If you only ever use the locally-declared functions in the function where they're declared, it will probably work.

    But declaring non-dynamically-located functions locally is generally a stupid idea... I have no idea who taught you to do that, but you should kick them hard in the shins.
    [I fail @ life]

  20. #5480
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Um, FreePlay, it's called passing by reference. Qt does it ALL THE TIME, so it must be valid.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  21. #5481
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    any1 for my prob?
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  22. #5482
    MiG
    MiG ist offline
    QJ Gamer Blue
    Points: 5.848, Level: 49
    Level completed: 49%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    499
    Points
    5.848
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    I've got my project compiling now... I Have no idea why but i tried the extern thing again, and it worked :|

    I swear it never worked before. :|

  23. #5483
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    hmmm...odd my prob just kinda disappeared i went back to my last setup and it still works fine i guess nvm now that it's working
    -= Double Post =-
    in the oslib what is the command to place a pixel i can only find the one's to draw lines,rectangles,and images
    Geändert von slicer4ever (07-13-2007 um 07:46 AM Uhr) Grund: Automerged Doublepost
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  24. #5484
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Can anyone help me?
    (page 546)

  25. #5485
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    after a quick scan right here:
    if(box.state==1 && box.jumpspeed==0)
    { box.y=box.y-0.8;
    box.jumpspeed+=0.3;}
    once the jumpspeed changes it doesn't again so it stays at that variable and a look into your code you probably want to change this to:

    if(box.state==1 && box.jumpspeed<3.5)
    { box.y=box.y-0.8;
    box.jumpspeed+=0.3;}

    edit:
    actually looking at it further you probably just want to drop the jumpstate and change it to:

    if(box.state==1)
    { box.y=box.y-0.8;
    box.jumpspeed+=0.3;}

    ok after reading a little bit more this is what i think your fully after:

    if(box.state==1 && box.jumpspeed<3.5)
    { box.y=box.y-0.8;
    box.jumpspeed+=0.3;}

    if (box.state==1 && box.jumpspeed>3.5)
    {box.y=box.y-0.3;
    //new line here to keep the jumpspeed increasing
    box.jumpspeed+=0.3;}

    if (box.state==1 && box.jumpspeed>=5);
    {
    box.state=2;
    }
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  26. #5486
    QJ Gamer Platinum
    Points: 57.528, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    h0000000rj
    Beiträge
    12.867
    Points
    57.528
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Um, FreePlay, it's called passing by reference. Qt does it ALL THE TIME, so it must be valid.
    Yes. I realize that. I meant that in the function *declaration* I don't think it's possible to use & on one of your args, e.g. "void doSomething(char &x)". I know you can pass something by reference like this:

    Code:
     int main()
     {
     	int a,b;
    	a=5;
    	b = 7;
    	foo(&a, &b);
    	printf("%d %d\n", a,b);
     }
     
     void foo(int *x, int *y)
     {
    	*x = 6;
    	*y = 8;
     }
    and slicer, I already told him that.
    Geändert von FreePlay (07-13-2007 um 11:37 AM Uhr) Grund: Automerged Doublepost
    [I fail @ life]

  27. #5487
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    No, C++ really supports the ampersand as parameter modifier to mark it as "by reference" without making it a pointer (ie it's safer as it cannot be null and avoids all the pointer-pitfalls).
    See f.e. http://www.tech-recipes.com/c_programming_tips1232.html
    Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
    Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
    Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
    Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.

  28. #5488
    QJ Gamer Platinum
    Points: 57.528, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    h0000000rj
    Beiträge
    12.867
    Points
    57.528
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    rrrrrreallly.

    well, I do mostly C, anyways.
    [I fail @ life]

  29. #5489
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    I'm fairly certain you can do it in C, too, but I'm not sure.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  30. #5490
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    I'm fairly certain you can do it in C, too, but I'm not sure.
    No, you can only pass by pointer in C.

    Edit: I stand corrected. I just tried this an you can pass by reference in C.


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:27 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .