Seite 85 von 340 ErsteErste ... 35 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 135 185 ... LetzteLetzte
Zeige Ergebnis 2.521 bis 2.550 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; Zitat von Waterbottle outisde of the mainfuction, yes. > more than < less than >= more than or equal <= ...

  
  1. #2521
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Waterbottle
    outisde of the mainfuction, yes.

    > more than
    < less than
    >= more than or equal
    <= less than or equal
    Thanks. :)



  2. #2522
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Code:
    ==	Equal to
    !=	Not equal to
    >	Greater than
    <	Less than
    >=	Greater than or equal to
    <=	Less than or equal to
    &	Bitwise AND
    |	Bitwise Inclusive OR
    ^	Bitwise Exclusive OR
    ~	Unary complement (bit inversion)
    <<	Shift Left
    >>	Shift Right

    ...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


  3. #2523
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    Code:
    ==	Equal to
    !=	Not equal to
    >	Greater than
    <	Less than
    >=	Greater than or equal to
    <=	Less than or equal to
    &	Bitwise AND
    |	Bitwise Inclusive OR
    ^	Bitwise Exclusive OR
    ~	Unary complement (bit inversion)
    <<	Shift Left
    >>	Shift Right
    || means or and & means and right?
    lol your about eight minutes late but thanks anyway.

    I just need to clarify something -
    Code:
    //let's say I have this
    void game() {
    if(pad.Buttons & PSP_CTRL_UP) {
    p1x = p1x + 2;
    }
    
    int main() {
    if(pad.Buttons & PSP_CTRL_UP) {
    ms = ms + 1;
    }
    
    if(pad.Buttons & PSP_CTRL_START) {
    game();
    }
    Now if I press up it would just change p1x and not ms?

  4. #2524
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Well I just saw the small list waterbottle gave you, so I did a quick write up of all I knew, then a few defintions I had to google about. And your 1/2 right...

    & is bitwise 'and'.
    | is bitwise 'or'.

    & will copy a bit to the result if it exists in both operands.

    Code:
    unsigned int a = 60;	// 60 = 0011 1100
    unsigned int b = 13;	// 13 = 0000 1101
    unsigned int c = 0;           
    
    c = a & b;                  // 12 = 0000 1100
    | will copy a bit if it exists in either operand.
    Code:
    unsigned int a = 60;	// 60 = 0011 1100 
    unsigned int b = 13;	// 13 = 0000 1101
    unsigned int c = 0;           
    
    c = a | b;                  //61 = 0011 1101
    You were talking about the logical operations of the two.

    ...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


  5. #2525
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    Well I just saw the small list waterbottle gave you, so I did a quick write up of all I knew, then a few defintions I had to google about. And your 1/2 right...

    & is bitwise 'and'.
    | is bitwise 'or'.

    & will copy a bit to the result if it exists in both operands.

    Code:
    unsigned int a = 60;	// 60 = 0011 1100
    unsigned int b = 13;	// 13 = 0000 1101
    unsigned int c = 0;           
    
    c = a & b;                  // 12 = 0000 1100
    | will copy a bit if it exists in either operand.
    Code:
    unsigned int a = 60;	// 60 = 0011 1100 
    unsigned int b = 13;	// 13 = 0000 1101
    unsigned int c = 0;           
    
    c = a | b;                  //61 = 0011 1101
    You were talking about the logical operations of the two.
    Yeah I was.

    The makefile for these includes would be:
    Code:
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <stdio.h>
    #include "graphics.h"
    would be
    Code:
    TARGET = lol
    OBJS = main.o graphics.o framebuffer.o
    
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBDIR =
    LIBS = -lpspgu -lz -lm
    LDFLAGS =
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = secret
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    I'm not good with makefiles so I haven't the foggiest idea.
    EDIT -
    Ok now I need some help with my code.
    Now this problem may seem obvious to solve but it isn't IMO...
    what it is that I defined all my variables in the main loop, but the function is outside of the main loop. The function refers to the variables, thus I get undefined errors.
    Help?

  6. #2526
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Add:
    Code:
    -lpspgum
    Else when using GU calls it may complain it about undefined references to GUM functions...

    ...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


  7. #2527
    QJ Gamer Blue
    Points: 4.521, Level: 42
    Level completed: 86%, Points required for next Level: 29
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    137
    Points
    4.521
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Hey,
    i was just trying to make a code to assign the value of 1 to base, if Circle is pressed...i tried this
    Code:
     if(pad.Buttons & PSP_CTRL_CIRCLE){                       
     base=1;
    }
    but that dosn't work ...it just assigns 1 to base and carries on with the rest of the code...i tired Break; but that doesnt work....what should i be doing to achive this?

    thanks for any help :)

  8. #2528
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    Add:
    Code:
    -lpspgum
    Else when using GU calls it may complain it about undefined references to GUM functions...
    Did that, and it still gives me the undeclared errors. (it was undeclared not undefined)

    Ok now I need help with this error:
    Code:
    main.c:23: error: syntax error before numeric constant
    Line 23:
    sceCtrlSetSamplingCycle(0);
    Maybe for the undeclared I could have a file with all the declarations(ie int, char, my colors) and #include it.
    [action=PSPduh]goes tries[/action]

    ok now this is annoying but I'm not giving up.
    Code:
    $ 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 main.c:9:
    lol.h:11: warning: implicit declaration of function 'RGB'
    lol.h:11: error: initializer element is not constant
    lol.h:12: error: initializer element is not constant
    lol.h:13: error: initializer element is not constant
    lol.h:14: error: initializer element is not constant
    lol.h:15: error: initializer element is not constant
    lol.h:16: error: initializer element is not constant
    lol.h:17: error: initializer element is not constant
    lol.h:20: error: initializer element is not constant
    lol.h:21: error: initializer element is not constant
    lol.h:22: error: initializer element is not constant
    main.c:24: error: syntax error before numeric constant
    main.c:24: warning: type defaults to 'int' in declaration of 'sceCtrlSetSampling
    Cycle'
    main.c:24: warning: data definition has no type or storage class
    main.c:25: warning: type defaults to 'int' in declaration of 'sceCtrlSetSampling
    Mode'
    main.c:25: warning: parameter names (without types) in function declaration
    main.c:25: warning: data definition has no type or storage class
    main.c: In function 'game':
    main.c:52: error: 'pad' undeclared (first use in this function)
    main.c:52: error: (Each undeclared identifier is reported only once
    main.c:52: error: for each function it appears in.)
    main.c: In function 'main':
    main.c:108: error: 'sceCtrlData' undeclared (first use in this function)
    lol.h:
    Code:
    Color blue = RGB(0,0,255);
        Color red = RGB(255,0,0);
        Color green = RGB(0,255,0);
        Color white = RGB(255,255,255);
        Color black = RGB(0,0,0);
        Color orange = RGB(255,140,0);
        Color yellow = RGB(255,255,0);
        
        //char the colors
        char p1c = white;
        char bc = red;
        char p2c = white;
    How the *bleep* do I fix that sceCtrlData error?

    @willolner - What do you mean it doesn't work? If it assigns 1 to base then isn't it mission accomplished?
    Geändert von PSPduh (01-15-2007 um 01:14 PM Uhr)

  9. #2529
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    PSPduh - Give me the snippet of your code that that is found in... Like line 20 to 30 or so...

    willolner - Im confused as well... Pressing O will set base to the value of 0. Unless somewhere else in the infinite loop your setting it NOT to 0, then it should be fine (im guessing your initlizing 'base' in your main loop, hence why it doesnt work as you thought)

    ...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


  10. #2530
    QJ Gamer Green
    Points: 9.253, Level: 64
    Level completed: 68%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Australia - A.C.T.
    Beiträge
    1.517
    Points
    9.253
    Level
    64
    Downloads
    0
    Uploads
    0

    Standard

    ok this code works fine when i make it a eboot but i need to make it a prx and when i try it doesn't load can anyone help
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <string.h>
    #include <pspctrl.h>
    
    
    PSP_MODULE_INFO("AUTOBOOT", 0x1000, 1, 1);
    
    
    
    
    void loadeboot(char *pbpath)
    {
            //char *pbpath;
            const u32 pbplen = strlen(pbpath)+1;
            struct SceKernelLoadExecParam eloader;
            eloader.args = pbplen;
            eloader.argp = pbpath;
            eloader.key = NULL;
            eloader.size = sizeof(eloader) + pbplen;
            if(sceKernelLoadExec(pbpath,&eloader)<0) {
            printf("EBOOT NOT FOUND, PLZ CHECK THE FILE AND TRY AGAIN\n");
            }
    }
    
    int main()
    {
    
        loadeboot("ms0:/PSP/GAME/irshell/EBOOT.PBP");
    
    
    }
    Code:
    TARGET = EBOOTLOADER
    OBJS = main.o
    BUILD_PRX=1
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    thx mafia1ft

  11. #2531
    QJ Gamer Silver
    Points: 8.201, Level: 61
    Level completed: 17%, Points required for next Level: 249
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Sheffield, UK
    Beiträge
    844
    Points
    8.201
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    All prx's need exports. Check C:\cygwin\usr\local\pspde v\psp\sdk\samples\prx\tes tprx for an example of exports.

  12. #2532
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    PRXs shouldnt have a PSP_MODULE_INFO, I think Ive heard that somewhere... But then again Ive been PSPless for 4 months now, so my memory is fading *sad song plays*

    ...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


  13. #2533
    QJ Gamer Silver
    Points: 8.201, Level: 61
    Level completed: 17%, Points required for next Level: 249
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Sheffield, UK
    Beiträge
    844
    Points
    8.201
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    They do, nothing in the PSPSDK will compile without the PSP_MODULE_INFO :)

  14. #2534
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    PSPduh: you seem to be lacking on some of the fundamentals of what you need to know. May I recommend taking my 'Full game' tutorial series (in 3 parts). It deals with variable scope and using multiple files/headers.

    Part one starts here: http://www.psp-programming.com/forum....php?topic=359

    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

  15. #2535
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    fixed

  16. #2536
    QJ Gamer Blue
    Points: 4.521, Level: 42
    Level completed: 86%, Points required for next Level: 29
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    137
    Points
    4.521
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Hey :)
    compiling this
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #define printf pspDebugScreenPrintf
    
    int i = 0;
    SceCtrlData pad;
    
    /* 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;
    }
    
    PSP_MODULE_INFO("PSPointles", 0, 1, 1);
    
    
                              
    
    int main ()
    {
    pspDebugScreenInit();
    SetupCallbacks();
    /*logo*/    
      printf("\n\\\\                ////  ////  ////     ////     /////////\n \\\\    ////\\\\    ////        ////     ////     ///   ///\n  \\\\  ////  \\\\  ////  ////  ////     ////     ///   ///\n   \\\\////    \\\\////  ////  ///////  ///////  /////////\n ");
    
    
    
    
    /*Menu code*/    
      printf("Welcome To Willo's Absalootly Pointless Game \nPress X To Continue: \n");
    
    while(1) {  
    sceCtrlReadBufferPositive(&pad, 1);
     if(pad.Buttons & PSP_CTRL_CROSS) {
                        break;
              }
    }
      
      pspDebugScreenClear();    
    /*Data input for User */
    
    
       printf("Press Triangle, and try to fill the screen with 1s")  
    while(1) {  
    sceCtrlReadBufferPositive(&pad, 1);
     if(pad.Buttons & PSP_CTRL_TRIANGLE) {
                        printf("1");
              }
    }
    cygwin says


    whats wrong with the sorce?

    thanks for any help :)

  17. #2537
    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

    Zitat Zitat von willolner
    Hey :)
    compiling this

    <omitted>

    cygwin says
    <omitted>

    whats wrong with the sorce?

    thanks for any help :)
    You forgot the semicolon on the printf before the second while loop.

  18. #2538
    QJ Gamer Blue
    Points: 4.521, Level: 42
    Level completed: 86%, Points required for next Level: 29
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    137
    Points
    4.521
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    *slaps self on forehead*
    lol
    thank you :)

  19. #2539
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    i dunno if anyone have any experience at all with SDL (Simple DirectMedia Layer) but i have some issues using the SDL_EnableKeyRepeat(3, 3); function but i really need to have that explained maybe an example or something cause i cant get it working at all :)

    Never mind ive solved the problem :)
    Geändert von PSP-Maniac (01-16-2007 um 11:56 AM Uhr)

  20. #2540
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Quick question:
    Is there any way to draw a circle? I mean is there already a predefined function that can draw a circle? Or will I have to go out of my way to make my own?

    @Insomniac -
    Thanks, I'll take a look. :)
    I just like to do things by myself :)
    I'll definitely try collision by myself. (Always something I wanted to try.)

  21. #2541
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    PSPduh - Using the graphics library I believe so. If not, just look in the Developers Dungeon for a thread on circles... I created it, i cant remember the name right now.

    ...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


  22. #2542
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    i am trying to how many space there is left on flash0:
    Code:
    int totalegrote=0;
    void check_space( const char *root)
    {
    	int dfd;
    	char next_root[256];
    	char next_write[256];
         sceIoUnassign("flash0:");
         sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);  
    
    	
    	dfd = sceIoDopen(root);
    	if(dfd > 0)
    	{
    		SceIoDirent dir;
    
    		while(sceIoDread(dfd, &dir) > 0)
    		{
    			if(dir.d_stat.st_attr & FIO_SO_IFDIR)
    			{
    				if(dir.d_name[0] != '.')
    				{
    					
    					build_path(next_root, root, dir.d_name, 1);
    					check_space(next_root);
    					
    				}
    			}
    	else
            {
            struct stat fileStats;
     
    	if (stat(root, &fileStats) == 0) {
            
                                      int grote=fileStats.st_size;
                                      totalegrote=totalegrote+grote;
                                                      
    		
    	}
    }
    		}
    		sceIoDclose(dfd);
    		
    	}
    }
    int main() {
    check_space("flash0:/");
    printf("\n%i", totalegrote);    
    return 0;
    }
    this should prinf the used space on flash0
    while i test this , it prints 6209536 (5,9mb) , thats fault there is more than 20mb used!!!
    what did i wrong??
    Geändert von hallo007 (01-17-2007 um 06:41 AM Uhr)

  23. #2543
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    PSPduh - Using the graphics library I believe so. If not, just look in the Developers Dungeon for a thread on circles... I created it, i cant remember the name right now.
    Hmm, I scanned graphics.c and I didn't find a circle function.
    Yeah I seen the thread for snippets and found one but I'm trying to make one but the best I have is a rounded rectangle.

    EDIT -
    If anybody wants the code for the rounded rectangle or a triangle here it is:
    Spoiler for code:

    Code:
    /*rounded rectangle by PSPduh 1/17/2007
    this function works theoretically, meaning I haven't tested it yet. (but it SHOULD work) */
    
    #include "graphics.h"
    
    void rr(int *x, int *y, int *diameter, Color color) {
         int dx = diameter-1;
         int dxx = diameter-2
    
         drawLineScreen(x, y, x-dx, y, color);
         drawLineScreen(x+dx, y+1, x-dx, y+diameter, color);
         drawLineScreen(x, y+diameter, x-dxx, y+diameter, color);
         drawLineScreen(x+1, y+1, x+1, y+dx, color);
    }
    
    /*This is how I came up with the function: Opened up paint, drew a 
    circle, and magnified it so I could see it pixel by pixel. 
    Then I found what relation all the coordinates of the pixels had with each other.  
    It did take me about thirty minutes to do this, even though I won't use it. :P 
    Still trying to figure out the circle code...(yes I want to make my own!)
    With a little modification it could be made to make a rounded rectangle that's filled in with the color.*/
    Code:
    //this is a triangle...this again is not tested but should work.
    void dt(x0, y0, x1, y1, x2, y2, Color color) {
    //x0 y0 is the top of the triangle, x1 y1 either point of the triangle, and x2 y2 is the other point
    drawLineScreen(x0, y0, x1, y1, color);
    drawLineScreen(x1, y1+1, x2, y2+1, color);
    drawLineScreen(x2, y2, x0, y1, color);
    //lol that was TOO easy...now how about we fill it with color?
    //the height of the triangle is equivalent to y1 or y2 - y0..how is this useful i don't know. =|
    //i'm thinking of using a for loop and putPixelScreen to fill in the triangle itself...hmph.
    //and yes I know I can use the GU to draw a triangle but I don't want to use the GU. (it's quite confusing)


    Um I need some help now...collision. Okay I know there are guides around the forums dealing with collision but I can make one by myself if I know the answer to this question:
    -When you blit the image, using x and y, what would the right side of the figure be? Top side? Bottom side? Left side? (In relation to x and y I mean. (like if the bottom side is y + something))
    Geändert von PSPduh (01-17-2007 um 04:44 PM Uhr)

  24. #2544
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    PSPduh - Your confusing.

    Collision, boudning boxes, compares to rectangles and checks whether one would be in side the other (rectangles as in just there size and placement).

    So, to start you off:
    Code:
    int Collision ( int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2 ) {
         if (blah collide checks==true) { return true; }
         else { return false; }
         }
    }
    Then youcould do:
    Code:
    if (Collision ( guy.x, guy.y, guy.width, guy.height,
                    enemy.x, enemy.y, enemy.width, enemy.height)) {
    // collision!
    } else {
    // no collision!
    }
    As you can guess...

    x1 = x placement of first object
    y1 = y placement of first object
    w1 = width of first object
    h1 = hieght of first object

    Same with the 2's but for the seconf object. And it doesnt have to be an image, you can compare numbers for all i care... In that LUA tutorial i did on bounding boxes (search these forums) I had 2 strings move around, and if collided print on them they collied, else print they didnt.

    Collision is very very easy stuff, should be the least of peoples worries when making agame.

    Also, to answer your question... The 'right' side of an image is the X placement of the image + the images width. So,,,

    guy.x + guy.width = right side of guy image

    ...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


  25. #2545
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    PSPduh - Your confusing.

    Collision, boudning boxes, compares to rectangles and checks whether one would be in side the other (rectangles as in just there size and placement).

    So, to start you off:
    Code:
    int Collision ( int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2 ) {
         if (blah collide checks==true) { return true; }
         else { return false; }
         }
    }
    Then youcould do:
    Code:
    if (Collision ( guy.x, guy.y, guy.width, guy.height,
                    enemy.x, enemy.y, enemy.width, enemy.height)) {
    // collision!
    } else {
    // no collision!
    }
    As you can guess...

    x1 = x placement of first object
    y1 = y placement of first object
    w1 = width of first object
    h1 = hieght of first object

    Same with the 2's but for the seconf object. And it doesnt have to be an image, you can compare numbers for all i care... In that LUA tutorial i did on bounding boxes (search these forums) I had 2 strings move around, and if collided print on them they collied, else print they didnt.

    Collision is very very easy stuff, should be the least of peoples worries when making agame.

    Also, to answer your question... The 'right' side of an image is the X placement of the image + the images width. So,,,

    guy.x + guy.width = right side of guy image
    Oh ok, I gotcha. I know collision is easy, I just was confused on what the right side of what image is and what side blah is etc.

    so:
    guy.x + guy.width = right side
    guy.x - guy.width = left side (?)
    guy.y + guy.height = top side
    guy.y - guy.height = bottom side

    Right?

  26. #2546
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    You arent thinking logically PSPduh... Why would we ADD the width of the image to its X coordinate, if the PSP blits images from teh top left (lua i mean).

    Subtracting the width from the X will give you leftside-width of what you want. The left side of the image is just its X value. Same with top of image ;)

    ...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


  27. #2547
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    You arent thinking logically PSPduh... Why would we ADD the width of the image to its X coordinate, if the PSP blits images from teh top left (lua i mean).

    Subtracting the width from the X will give you leftside-width of what you want. The left side of the image is just its X value. Same with top of image ;)
    See I didn't now where the PSP blits the image. Whether it be the center, top left, bottom, but now I know that it is the top left. OH I GET it.
    so...(let's try this again lol)

    Code:
    left side = x
    right side = x + width
    top side = y
    bottom side = y - height
    Now I'm sure that's right?
    Still need to find out how to draw a circle. I just don't like using outside images...I like doing everything inside the code, for some reason it feels like I have more control over everything.

    And now that I know what the sides are then I can do the collision...but dang it I still need to figure out how to do speed.

    WAIT HOLY FO SHNIZZLE I THINK I GOT TEH SPEEd.

  28. #2548
    Points: 3.751, Level: 38
    Level completed: 68%, Points required for next Level: 49
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Beiträge
    48
    Points
    3.751
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Here's a circle drawing function a found awhile back, its not a perfect circle, but good enough for my purposes at least. It's also fairly fast. Just change DrawPixel() to whatever your pixel drawing function is. I think it's pretty self explanatory on how to use it.

    Code:
    void drawCircle(int x, int y, int r, Color color)
    {
       int pos_x,
       pos_y = -r,
       tx = 0,
       ty = 4*r,
       a = 0,
       b = 2*ty+9,
       x1 = int(r*0.707010678 + 0.5);
     
       DrawPixel(x+r,y,color);
       DrawPixel(x-r,y,color);
       DrawPixel(x,y+r,color);
       DrawPixel(x,y-r,color);
       DrawPixel(x+x1,y+x1,color);
       DrawPixel(x+x1,y-x1,color);
       DrawPixel(x-x1,y+x1,color);
       DrawPixel(x-x1,y-x1,color);
     
       for(pos_x = 1;pos_x < x1;pos_x++)
       {
     a += 8;
     tx += a;
     if(tx > ty)
     {
        pos_y++;
        b -= 8;
        ty += b;
     }
     
     DrawPixel(x+pos_x,y+pos_y,color);
     DrawPixel(x-pos_x,y+pos_y,color);
       
     DrawPixel(x+pos_x,y-pos_y,color);
     DrawPixel(x-pos_x,y-pos_y,color);
       
     DrawPixel(x+pos_y,y+pos_x,color);
     DrawPixel(x-pos_y,y+pos_x,color);
       
     DrawPixel(x+pos_y,y-pos_x,color);
     DrawPixel(x-pos_y,y-pos_x,color);
       }
    }

  29. #2549
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    *takes off belt*

    PSPduh... you know I dont like being lied to... ok, maybe you didnt know but you know now... The PSP blits the image from the top left of the image... so... the top of the image is the y coordinate, the left is the x, the bottom is y + height, the right is x + width.

    *puts belt back on before pants fall down and lets PSPDuh away with a warning and a firm shaking finger*

    ...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


  30. #2550
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    *takes off belt*

    PSPduh... you know I dont like being lied to... ok, maybe you didnt know but you know now... The PSP blits the image from the top left of the image... so... the top of the image is the y coordinate, the left is the x, the bottom is y + height, the right is x + width.

    *puts belt back on before pants fall down and lets PSPDuh away with a warning and a firm shaking finger*
    Er?

    Oh yeah I forgot that the y increments downward...whoops. :o

    @trevis - thanks. :)
    Now I need to tweak it to make a filled in circle. (which is what I need)
    Now I think I can commence making the actual game...


 

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 .