Homebrew Homebrew Development

Manurocker95

Game Developer & Pokémon Master
Member
Joined
May 29, 2016
Messages
1,511
Trophies
0
Age
28
Location
Madrid
Website
manuelrodriguezmatesanz.com
XP
2,769
Country
Spain
Hi there, can someone explain me how to use pictures with Citro2D (Citro3D?), as I don't understand the devkitpro's "gpusprites" example (they use a lot of sprites here, and from what I have understood, it all goes into 1 big t3x spritesheet ?)
Thanks to anyone who can point me the way to use pictures with Citro !

I recommend you to use PP2D. It is a modification of Citro2D so noob friendly. You can see my template here . You just need to create the texture with
Code:
pp2d_load_texture_png(TEXTURE_SPRITESHEET_ID,spritesheet);

and draw it with something like:

Code:
//Top screen
pp2d_begin_draw(GFX_TOP, GFX_LEFT);
pp2d_draw_texture_part(TEXTURE_SPRITESHEET_ID, xPosition, yPosition, xOffset, yOffset, SpriteWidth, SpriteHeight);
// Bottom screen
pp2d_draw_on(GFX_BOTTOM, GFX_LEFT);
pp2d_draw_texture_part(TEXTURE_SPRITESHEET_ID, xPosition, yPosition, xOffset, yOffset, SpriteWidth, SpriteHeight);
pp2d_end_draw();


For text:

Code:
pp2d_draw_text(xPosition, yPosition, sizeX, sizeY, rgbColor, "HELLO WORLD!!");
 
  • Like
Reactions: randomdev

randomdev

Well-Known Member
Member
Joined
Jun 7, 2015
Messages
155
Trophies
0
XP
235
Country
Brazil
I recommend you to use PP2D. It is a modification of Citro2D so noob friendly. You can see my template here . You just need to create the texture with
Code:
pp2d_load_texture_png(TEXTURE_SPRITESHEET_ID,spritesheet);

and draw it with something like:

Code:
//Top screen
pp2d_begin_draw(GFX_TOP, GFX_LEFT);
pp2d_draw_texture_part(TEXTURE_SPRITESHEET_ID, xPosition, yPosition, xOffset, yOffset, SpriteWidth, SpriteHeight);
// Bottom screen
pp2d_draw_on(GFX_BOTTOM, GFX_LEFT);
pp2d_draw_texture_part(TEXTURE_SPRITESHEET_ID, xPosition, yPosition, xOffset, yOffset, SpriteWidth, SpriteHeight);
pp2d_end_draw();


For text:

Code:
pp2d_draw_text(xPosition, yPosition, sizeX, sizeY, rgbColor, "HELLO WORLD!!");
Thank you! I'll give a try this afternoon.
 

Magicrafter13

Well-Known Member
Member
Joined
Feb 19, 2017
Messages
134
Trophies
0
Website
matthewrease.net
XP
242
Country
United States
Hi there, can someone explain me how to use pictures with Citro2D (Citro3D?), as I don't understand the devkitpro's "gpusprites" example (they use a lot of sprites here, and from what I have understood, it all goes into 1 big t3x spritesheet ?)
Thanks to anyone who can point me the way to use pictures with Citro !
I don't know if I quite understand your question, but I remember having problems understanding Citro2D at first as well. Maybe some of my projects could help? The 2 projects of mine that use Citro2D, are: BreakoutRedux, and Dungeon-Escape (on my GitHub).

--------------------- MERGED ---------------------------

I recommend you to use PP2D. It is a modification of Citro2D so noob friendly. You can see my template here . You just need to create the texture with
Code:
pp2d_load_texture_png(TEXTURE_SPRITESHEET_ID,spritesheet);

and draw it with something like:

Code:
//Top screen
pp2d_begin_draw(GFX_TOP, GFX_LEFT);
pp2d_draw_texture_part(TEXTURE_SPRITESHEET_ID, xPosition, yPosition, xOffset, yOffset, SpriteWidth, SpriteHeight);
// Bottom screen
pp2d_draw_on(GFX_BOTTOM, GFX_LEFT);
pp2d_draw_texture_part(TEXTURE_SPRITESHEET_ID, xPosition, yPosition, xOffset, yOffset, SpriteWidth, SpriteHeight);
pp2d_end_draw();


For text:

Code:
pp2d_draw_text(xPosition, yPosition, sizeX, sizeY, rgbColor, "HELLO WORLD!!");

A year ago I would have agreed with this, but once you figure out what to do, Citro2D is incredibly easy. And PP2D is not kept up to date I definitely would not recommend it. I don't even think the creator has the repo up anymore...
 
  • Like
Reactions: randomdev

randomdev

Well-Known Member
Member
Joined
Jun 7, 2015
Messages
155
Trophies
0
XP
235
Country
Brazil
I don't know if I quite understand your question, but I remember having problems understanding Citro2D at first as well. Maybe some of my projects could help? The 2 projects of mine that use Citro2D, are: BreakoutRedux, and Dungeon-Escape (on my GitHub).

--------------------- MERGED ---------------------------



A year ago I would have agreed with this, but once you figure out what to do, Citro2D is incredibly easy. And PP2D is not kept up to date I definitely would not recommend it. I don't even think the creator has the repo up anymore...
Thank you, yeah I think pp2d is too old and from what i saw in your homebrews, using Citro2d directly seems easy.
 

Manurocker95

Game Developer & Pokémon Master
Member
Joined
May 29, 2016
Messages
1,511
Trophies
0
Age
28
Location
Madrid
Website
manuelrodriguezmatesanz.com
XP
2,769
Country
Spain
A year ago I would have agreed with this, but once you figure out what to do, Citro2D is incredibly easy. And PP2D is not kept up to date I definitely would not recommend it. I don't even think the creator has the repo up anymore...

It worked flawlessly for me and there are a lot of mirrors of PP2D. I just recommended what I used some time ago
 

Vovonator

Member
Newcomer
Joined
Dec 5, 2018
Messages
15
Trophies
0
Age
26
XP
103
Country
Brazil
D

Deleted User

Guest
I was wondering if there was a doc of citro2d/3d i am a absolute beginner at 3ds homebrew and any help would be much appreciated thankyou
 

Turumarth

New Member
Newbie
Joined
Nov 14, 2019
Messages
1
Trophies
0
Age
32
XP
36
Country
Canada
Hey I am an absolute beginner too; I made my first hello world on 3ds yesterday :D

I found this for citro2d citro2d devkitpro org / index html

Sorry I just joined the site so I can't post links yet!
Let me know if you have any luck finding one for citro3d!
 
  • Like
Reactions: Deleted User
D

Deleted User

Guest
Hey I am an absolute beginner too; I made my first hello world on 3ds yesterday :D

I found this for citro2d citro2d devkitpro org / index html

Sorry I just joined the site so I can't post links yet!
Let me know if you have any luck finding one for citro3d!

Okay great It is nice to know that I am not the only one who is a beginner :yay:
 
D

Deleted User

Guest
I was wondering if anybody could give me some pointers on making a simple 2d game for 3ds homebrew all I need is the basic way you would make a sprite move with a button press I am trying to alter the devkitPro sample gpusprites and I understand it would be something like this

if (kDown & KEY_LEFT)
{
set sprite position to 5 5
}

but it does not work any help would be so appriciated thanks
 

catlover007

Developer
Developer
Joined
Oct 23, 2015
Messages
714
Trophies
1
XP
3,837
Country
Germany
I was wondering if anybody could give me some pointers on making a simple 2d game for 3ds homebrew all I need is the basic way you would make a sprite move with a button press I am trying to alter the devkitPro sample gpusprites and I understand it would be something like this

if (kDown & KEY_LEFT)
{
set sprite position to 5 5
}

but it does not work any help would be so appriciated thanks
sorry, but it seems to me, that you don't understand the code of the example. Maybe you should start by disecting it and try to understand the meaning of the individual code pieces. Then show me where in the code the position of the sprites is set and based upon what value?
 

ShroomKing

Somebody
Member
Joined
Mar 3, 2017
Messages
470
Trophies
0
Age
29
Location
in bed
XP
1,947
Country
United States
You seem lost...
It would be easier if you get comfortable with the language first, then play around with openGL or another graphics api. (On the PC, with proper documentation and a debugger)

Anyway, i threw together a simple example for moving a sprite:

Code:
#include <citro2d.h>
#include <3ds.h>

#define SCREEN_WIDTH  400
#define SCREEN_HEIGHT 240

int main() {
    romfsInit();
    gfxInitDefault();
    C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
    C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
    C2D_Prepare();
    consoleInit(GFX_BOTTOM, NULL);

    C3D_RenderTarget* top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
    C2D_SpriteSheet spriteSheet = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x");
    C2D_Sprite sprites;

    C2D_SpriteFromSheet(&sprites, spriteSheet, 0);
    C2D_SpriteSetCenter(&sprites, 0.5, 0.5);
    C2D_SpriteSetPos(&sprites, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);

    while (aptMainLoop()) {
        hidScanInput();
        u32 kDown = hidKeysDown();
        u32 kHeld = hidKeysHeld();

        if (kDown & KEY_START)
            break;
       
        if (kHeld & KEY_UP)
            C2D_SpriteMove(&sprites, 0, -1.75);
        if (kHeld & KEY_DOWN)
            C2D_SpriteMove(&sprites, 0, 1.75);
        if (kHeld & KEY_LEFT)
            C2D_SpriteMove(&sprites, -1.75, 0);
        if (kHeld & KEY_RIGHT)
            C2D_SpriteMove(&sprites, 1.75, 0);

        C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
        C2D_TargetClear(top, C2D_Color32f(0.0, 0.0, 0.0, 1.0));
        C2D_SceneBegin(top);
        C2D_DrawSprite(&sprites);
        C3D_FrameEnd(0);
    }
    C2D_SpriteSheetFree(spriteSheet);
    C2D_Fini();
    C3D_Fini();
    gfxExit();
    romfsExit();
    return 0;
}

Also, please use code blocks.
 
  • Like
Reactions: Deleted User
D

Deleted User

Guest
You seem lost...
It would be easier if you get comfortable with the language first, then play around with openGL or another graphics api. (On the PC, with proper documentation and a debugger)

Anyway, i threw together a simple example for moving a sprite:

Code:
#include <citro2d.h>
#include <3ds.h>

#define SCREEN_WIDTH  400
#define SCREEN_HEIGHT 240

int main() {
    romfsInit();
    gfxInitDefault();
    C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
    C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
    C2D_Prepare();
    consoleInit(GFX_BOTTOM, NULL);

    C3D_RenderTarget* top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
    C2D_SpriteSheet spriteSheet = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x");
    C2D_Sprite sprites;

    C2D_SpriteFromSheet(&sprites, spriteSheet, 0);
    C2D_SpriteSetCenter(&sprites, 0.5, 0.5);
    C2D_SpriteSetPos(&sprites, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);

    while (aptMainLoop()) {
        hidScanInput();
        u32 kDown = hidKeysDown();
        u32 kHeld = hidKeysHeld();

        if (kDown & KEY_START)
            break;
     
        if (kHeld & KEY_UP)
            C2D_SpriteMove(&sprites, 0, -1.75);
        if (kHeld & KEY_DOWN)
            C2D_SpriteMove(&sprites, 0, 1.75);
        if (kHeld & KEY_LEFT)
            C2D_SpriteMove(&sprites, -1.75, 0);
        if (kHeld & KEY_RIGHT)
            C2D_SpriteMove(&sprites, 1.75, 0);

        C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
        C2D_TargetClear(top, C2D_Color32f(0.0, 0.0, 0.0, 1.0));
        C2D_SceneBegin(top);
        C2D_DrawSprite(&sprites);
        C3D_FrameEnd(0);
    }
    C2D_SpriteSheetFree(spriteSheet);
    C2D_Fini();
    C3D_Fini();
    gfxExit();
    romfsExit();
    return 0;
}

Also, please use code blocks.

WOW THANK YOU SO MUCH!!!:yay: this is great I was going to get into opengl but the installation was vague and the guide I followed had me download about five different programs THANKS AGAIN THIS IS GREAT!!!:yay: I also have code blocks it is a great IDE
 
  • Like
Reactions: ShroomKing

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BigOnYa @ BigOnYa:
    Ok goodnight. Have a talk with your older brother when you get a chance. Don't be ashamed, we all have issues in our life, so you are not alone.
  • K3Nv2 @ K3Nv2:
    [He will] only make $1.5 million per night after taxes. Poor guy
  • BigOnYa @ BigOnYa:
    My stupid computer chair keeps slowly going down, but I don't notice it goes down, until I'm like reaching up to my desk. I just bought this f er last year.
  • BakerMan @ BakerMan:
    Does Bruno Mars is gay?
  • BigOnYa @ BigOnYa:
    K3nv2 would know...
  • K3Nv2 @ K3Nv2:
    Only for Bakers
    +1
  • BigOnYa @ BigOnYa:
    I heard he has a Wario fetish, but only if no Wizards are around.
  • BigOnYa @ BigOnYa:
    jk with you Bakerman, much love. fist bump.
  • K3Nv2 @ K3Nv2:
    He really knows how to kneed the dough
  • BigOnYa @ BigOnYa:
    Man. I can't wait til CTGP 8 comes out on Switch, been waiting forever.
  • BigOnYa @ BigOnYa:
    Boners Makes me wanna play Duck Hunt NES
  • K3Nv2 @ K3Nv2:
    Pooping nice
  • BigOnYa @ BigOnYa:
    What is a "Poop de Boop"? I've heard it mentioned several times now but have no idea and can't find anything online bout it. Is it a British term for restroom/bathroom or something?
  • Psionic Roshambo @ Psionic Roshambo:
    It is a perfume
    +1
  • K3Nv2 @ K3Nv2:
    Why do we have virgin islands if it's populated
    +1
  • BigOnYa @ BigOnYa:
    They should change the name to K3Nv2's Mom islands. (Or before he responds, My Wifeys Islands)
  • K3Nv2 @ K3Nv2:
    Nah me saying that's more predictable than you talking about my mom
    +1
  • K3Nv2 @ K3Nv2:
    Hence urewifes so predictable she'd buy every man on the virgin islands
  • K3Nv2 @ K3Nv2:
    Or they buy her
  • BigOnYa @ BigOnYa:
    true dat
    BigOnYa @ BigOnYa: true dat