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,835
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
  • RedColoredStars @ RedColoredStars:
    Speaking of PLaystation. I see Evilnat put out a beta for PS3 CFW 4.91.2 on the 22nd.
  • K3Nv2 @ K3Nv2:
    Don't really see the point in updating it tbh
  • BigOnYa @ BigOnYa:
    Yea you right, I thought about updating my PS3 CFW to 4.91, but why really, everything plays fine now. I guess for people that have already updated past 4.9 it would be helpful.
  • K3Nv2 @ K3Nv2:
    Idk if online servers are still active that would be my only thought
    +1
  • BigOnYa @ BigOnYa:
    Thats true, personally I don't play it online at all, in fact, I deleted all wifi details on it once I installed CFW, so it won't connect and auto-update itself
  • BigOnYa @ BigOnYa:
    I play most games that are on both PS3/360 strickly on the 360, but PS3 exclusives are really only games I play on the PS3 (You know me, I'm more of a Xbox junkie)
  • K3Nv2 @ K3Nv2:
    Ps3 really has no titles worth going online
  • BigOnYa @ BigOnYa:
    what is nps?
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, what about GTA v onl... O Yea the PS3 versión got discontinued
  • K3Nv2 @ K3Nv2:
    I feel like the world's cheapest pc build can play gtaV
  • K3Nv2 @ K3Nv2:
    In modern standards
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, then why mine can't?
  • BigOnYa @ BigOnYa:
    @K3Nv2 What is nps you mentioned?
  • K3Nv2 @ K3Nv2:
    Because your pc has a hamster innit
    +3
  • BakerMan @ BakerMan:
    R.I.P. LittleBigPlanet PS3 servers
  • BakerMan @ BakerMan:
    LBP2 still the goat tho
  • K3Nv2 @ K3Nv2:
    That can be played on ps5 iirc
  • BigOnYa @ BigOnYa:
    I'm surprised any PS3 servers are still up, tbh
  • K3Nv2 @ K3Nv2:
    Alot of manufactures do care about older consoles they just want to whine about piracy
    +2
  • S @ salazarcosplay:
    @BigOnYa I had 4.89 hfw on super slim that was great, but when I got a new hard disk I forgot where the guide was and could only find a guide for 4.90 and its resources
  • S @ salazarcosplay:
    @BigOnYa I think another reason to want to update is if the hfw is at the level of the fw
  • S @ salazarcosplay:
    you can sync trophies
  • BigOnYa @ BigOnYa:
    Yea that's what I sitting on now- 4.9, and it seems fine, have had no issues at all
  • S @ salazarcosplay:
    I don't know if people play online or such
  • K3Nv2 @ K3Nv2:
    My ps3 short circuited during a deep clean still salty about it after downloading 2tbs worth but SteamDeck okay with emulation still just can't run mgs4 worth shit
    K3Nv2 @ K3Nv2: My ps3 short circuited during a deep clean still salty about it after downloading 2tbs worth but...