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 joseph10444 wait so in C you cannot define where text goes like LUA??? you have to skip lines?? ...
-
06-09-2008, 04:52 PM #8611QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
-
06-09-2008, 05:00 PM #8612Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
-
06-09-2008, 05:13 PM #8613QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Yeah. If you are constantly changing the x,y values to custom ones each time you call printf, I'd make a function to do that >_>
Of course you would need to learn about variable arguments, but would make things easier if you needed a function similar to the one aboveCode:int pspDebugScreenPrintfXY(int x, int y, char* string, ...);
And to answer your second question.
Variables, function names, types, etc... are all case sensitive so case does matter. If everything is declared in all caps, then use it as it was declared.
Anyway, your code looks fine.[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
06-09-2008, 05:13 PM #8614words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
I believe the debug console uses a character place x and y value, not pixel x and y values (so (4,10) will move over 4 characters spots and down 10 (from the top left))

...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
-
06-09-2008, 05:35 PM #8615Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
oh...
now thats kinda CHEAP!!!
..
but thats another problem Moca
in my code...
OH LOL NVM..
i seemed to have forgot the ";" at the end of my SetXY
..
-
06-09-2008, 07:35 PM #8616Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
how can you set text on colour?
im sorry im so new to this...
i have to read more tutorials on calling functions
-
06-09-2008, 08:49 PM #8617QJ Gamer Gold
- Registriert seit
- Feb 2007
- Ort
- Houston, Texas
- Beiträge
- 3.349
- Points
- 20.111
- Level
- 89
- Downloads
- 0
- Uploads
- 0
I am a new learning developer, but I think its like this:
pspDebugScreenPrint (X, Y, Text, Color);
Just try popping in some hex values for a color, try that.
PSN: TrueDef
AIM: TrueDef91
Prestige 7 On COD4
-
06-09-2008, 08:51 PM #8618It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
No, wrong, false.
Code:pspDebugScreenSetTextColor(u32 color)
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
06-09-2008, 08:55 PM #8619QJ Gamer Gold
- Registriert seit
- Feb 2007
- Ort
- Houston, Texas
- Beiträge
- 3.349
- Points
- 20.111
- Level
- 89
- Downloads
- 0
- Uploads
- 0
-
06-09-2008, 09:03 PM #8620Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
wow i have to put in a lot of these pspDebugScreenSetxxxxxxxx xxxx
do i replace u32 or colour?
-
06-09-2008, 09:10 PM #8621It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Both. The u32 just signifies that what you're putting in there is of type u32--that is, unsigned 32-bit integer.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
06-09-2008, 09:35 PM #8622Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
can i replace colour with any colour lke blue
-
06-09-2008, 09:36 PM #8623It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You need the hexcode for the color. You can't just put in "blue".
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
06-09-2008, 09:41 PM #8624QJ Gamer Gold
- Registriert seit
- Feb 2007
- Ort
- Houston, Texas
- Beiträge
- 3.349
- Points
- 20.111
- Level
- 89
- Downloads
- 0
- Uploads
- 0
So like this:
Code:pspDebugScreenSetTextColor(u32 FFFFFF)
PSN: TrueDef
AIM: TrueDef91
Prestige 7 On COD4
-
06-09-2008, 09:45 PM #8625It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
-
06-09-2008, 09:48 PM #8626QJ Gamer Gold
- Registriert seit
- Feb 2007
- Ort
- Houston, Texas
- Beiträge
- 3.349
- Points
- 20.111
- Level
- 89
- Downloads
- 0
- Uploads
- 0
Ok, cool, thanks man, even though I didn't need this, I know now for the future.
PSN: TrueDef
AIM: TrueDef91
Prestige 7 On COD4
-
06-10-2008, 07:48 AM #8627QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
in c++ i use
#define blue 0x0000ff
pspDebugScreenSetTextColo r(blue);
printf("Helloworld");
prints helloworld in blue text color! But in C it may be different.
-
06-10-2008, 07:49 AM #8628QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Nope, C would be the same.
-
06-10-2008, 07:49 AM #8629QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
also i dont know why the r is taken a space when i edit it it doesn't appear like that ( pspDebugScreenSetTextColo ur(Blue); )
-=Double Post=-
Ok cool
-
06-10-2008, 07:52 AM #8630QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
The space appears to prevent exploits, which exploits I'm not sure.
Also, when you post any code, place it in the [CODE] tags, please. :)
-
06-10-2008, 07:56 AM #8631QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Ok will do
-
06-10-2008, 08:02 AM #8632QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 96
- Points
- 3.008
- Level
- 33
- Downloads
- 0
- Uploads
- 0
Scrolling in C
Hey all,
Can someone explain me how I make a scrolling map in C.
I've made a map like this:
int main() {
Image* texture1Img;
Image* texture2Img;
Image* tree1Img;
Image* wall1Img;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
texture1Img = loadImage("texture1.png") ;
texture2Img = loadImage("texture2.png") ;
tree1Img = loadImage("tree1.png");
wall1Img = loadImage("wall1.png");
int x = 0;
int y = 0;
sceDisplayWaitVblankStart ();
while (x < 2000) {
while (y < 2000) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, texture1Img, x, y);
y += 32;
}
x += 32;
y = 0;
}
blitAlphaImageToScreen(0 ,0 ,32 , 32, tree1Img, 50, 50);
flipScreen();
}
Thats all now I've drawn an texture as a background from 2000 x and 2000 y.
All I want now is that it must scroll when playerx and playery gets at some kind of distance from the screen 480, 272.
I think I must make a 2 variables that got the value of the screen height and width, then when player gets at 400 or 200 the screen moves.
But I don't really know how to do that in C, can someone explain me? I would really apreciate that!
-
06-10-2008, 09:05 AM #8633QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Have two variables that keeps track of what point in the world the top-left corner of the screen represents. Move that around when the player is near the edge of the screen. Then subtract these co-ordinates from the co-ordinates of the object you're drawing to get the position on the screen where you have to draw it.
-
06-10-2008, 09:42 AM #8634QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 96
- Points
- 3.008
- Level
- 33
- Downloads
- 0
- Uploads
- 0
So you mean:
top-left corner is at begin x=0 y=0
screenx=0
screeny=0
when player=screenx+480-100
screenx=screenx+playerxsp eed
okay lets say now
screenx=200
screeny=0
This is till where I understand it..
You say subtract these coördinates from the object your drawing to get the position on the screen where you have to draw it.
I don't understand that, the problem is not that I don't know where to draw the (player-)object.
I don't know how to move the screen to another position, the (player-)object got already the right position.
Or do you mean something else with object.
-
06-10-2008, 11:08 AM #8635NetGameOrb Maker

- Registriert seit
- Jan 2008
- Ort
- New York
- Beiträge
- 683
- Points
- 6.138
- Level
- 50
- My Mood
-
- Downloads
- 2
- Uploads
- 0
maybe you can try something like this
-----------------------------------------------------------------code--------------
screenx = 0 //screen x
screeny = 0 //and y
playerx =0 //player x
playery =0 //player y
mapW = 512 //map width
mapH = 512 //map hight
blitAlphaImageToScreen(0 ,0 ,480, 272, mapImg, screenx,screeny); //blit the map from screen x and screen y
blitAlphaImageToScreen(0 ,0 ,32, 32, playerImg, playerx,playery);//blit player
if (player x>480) {
playerx = 0; //reset the player x like what Zelda does
screenx = screenx + 480; //move screenx in map to the left
if (screenx > mapW) {
screenx = mapW; //make sure that screen x does not pass the map wight if so the set it to map wight
}
}
...
---------------------------------------------------------------------end of code-----
so on and so on
do you understand now?
:)GameLive name changed to NetGameOrb, Project is now online in Beta stage. Everyone encourage to register so they get news about the project and ability to play the games with NetGameOrb Support online. More info on site.
Stats Blog:http://netgameorb.blogspot.com/
Website:http://www.netgameorb.com/
-
06-10-2008, 11:44 AM #8636Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
how can i find Hex values of colours??
all i know is RGB-ing lol
-
06-10-2008, 01:19 PM #8637Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
The PSP takes colour values in 0xAABBGGRR format.
Which you can create using the GU_RGBA macro.
Is white, fuly opaque (0xFFFFFFFF).Code:unsigned int color = GU_RGBA(255, 255, 255, 255);
0xFF0000FF is red.
0xFF00FF00 is green.
0xFFFF0000 is blue.
255 is 0xFF in hex.
Google is good for decimal to hex convertors.
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
-
06-10-2008, 01:21 PM #8638Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
okay ty..
not really understood it but okay ill have to search google
-
06-10-2008, 04:01 PM #8639Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
okay so this is my code
so the "hello" would appear in whiteCode:pspDebugScreenSetXY(4,13); printf("hello"); pspDebugScreenSetTextColor(green); pspDebugScreenSetXY(6,15); printf("hello hello"); pspDebugScreenSetXY(4,17); printf("hello hello hello");
then the "hello hello" would appear in green because it was defined earlier
but i want the "hello hello hello" to appear back in white...
do i have to set the colour to white all over again??
-
06-10-2008, 04:12 PM #8640QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Read up on the HEX number system: http://www.danbbs.dk/~erikoest/hex.htm
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum