StarBugz game prototype and engine (using Gu) with source

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

StarBugz game prototype and engine (using Gu) with source

Post by dr_watson »

This is a prototype of StarBugz, a Space Invader clone. The purpose of the project was to get myself familiar with programming PSP games, and hopefully to build up a simple game engine in the process.

After working on the project in my spare time for nearly a month, the hardware accelerated 2D game engine, called JGE (Jas Game Engine), was basically done. JGE uses Gu libraries for image rendering and StarBugz now becomes a small showcase of the engine, demonstrating various features of it.

Here are few screen shots of StarBugz:

Image
Image
Image

I've learned everything about programming the PSP from the PSP homebrew community, including this forum and source code from http://svn.ps2dev.org. I guess it's time for me to give a small contribution back to the community. Here is the complete source code of StarBugz prototype, the game engine JGE and also a small demo of the engine.

(Just a side note: The classes/functions naming of JGE is based heavily on HGE, a Windows based 2D game engine, as I found HGE such a good game engine to play with! Thanks Haaf! In fact, my goal is evetually have the same source code of StarBugz to build with JGE and HGE at the same time!)

StarBugz/JGE/JGE Demo source 375KB
Firmware 1.50 binary(MD5:f291af03ab01033e7d63a8ba6478d64c) 815KB

Special thanks to my lovely wife for her support and beta testing StarBugz for me.
rmedtx
Posts: 14
Joined: Tue Sep 13, 2005 11:44 pm
Location: USA
Contact:

Post by rmedtx »

Excellent work dr_watson, I was playing your game and it rocks. Very nicely done. I hope we can see more soon.
BlackPhoenix
Posts: 4
Joined: Tue Dec 06, 2005 2:59 am

Post by BlackPhoenix »

Good start to maybe a classic PSP game ;) I took the game out with me last night and let my friend's kids play on it, they loved it.. but got really frustrated at the boss fights.. you can't evade his shots, allowing free movement across the game screen. Thanks for the source, I've been learning C++ for the majority of this year, done a few x86 games and got a PSP for my birthday, its been quite a learning experience and late nights.

Keep releasing new versions and I will download them ;)
Chrighton
Posts: 58
Joined: Wed Jun 15, 2005 8:24 pm

Post by Chrighton »

Nicely done, dr_watson :)
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Im loving your engine dr_watson! Ive been PMing you questions and i thnik you for all your help, and you asked me to post here so that other people can share the answers too, so im going to post some of the questions ive asked so far. :)
The engine seems to be cutting off the bottom pixles of everything i display!

The files need to be to the power of 2, so it would be best to put alot of sprites onto one image, for example 256x256 or 512x512 and create quads out of that BIG image because you'll try to avoid switching textures.

Im having trouble with the fonts engine..

You need to create your font by using LMNOpc's Bitmap Font Builder.
If you take a look of the StarBugz source, for example, in Invader.h:

JLBFont* mFont;

then in Invader.cpp:
mFont = new JLBFont(this, "Res/f3", 16, true);

Note that for the first parameter of JLBFont, you need to pass in pointer of class derived from JGE! 16 is the height of the font!

Thanks for all your help, but how do i make a .png image from the font builder? It seems to only let me do BMP TGA and RAW.
and i changed a 32 bit TGA into a png, and now im getting a TON of multiple definition errors when i compile, one for each member of JLBFont.
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

Post by dr_watson »

No worries! I'm so glad that someone is actually using my little engine for something ;)

Obviously you need some tools to convert those BMP/TGA into PNG, for example PaintShop Pro.

For the font to be used in JGE, you also need to create a data file by using Bitmap Font Builder's menu option: "Save Font Widths (L+ABC format)". Say the name of your font is "xyz", you will have 2 files, "xyz.png" and "xyz.dat" evetually.

When you create your JLBFont object, supposed the height is 16:

mFont = new JLBFont(this, "Res/xyz", 16, true);

What errors did you have exactly? Can you post code segments and errors so that I can check them out?
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Yeah i changed it into a png with photoshop. I already got the .dat file too.

Im using Dev-C++ as my IDE, so this is what i get in the compile log:

Code: Select all

Compiler: PSP
Executing  make...
make.exe -f "Makefile" all
psp-gcc -I. -IC:/cygwin/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall   -L. -LC:/cygwin/usr/local/pspdev/psp/sdk/lib   main.o JGE/JGE.o -lpng -lz -lm -lmikmod -lmmio -lpspaudiolib -lpspaudio -lpspgu -lstdc++  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspuser -lpspkernel -o PSPopups.elf

JGE/JGE.o: In function `JLBFont::JLBFont(JGE*, char const*, int, bool)':
JGE.cpp:(.text+0x2694): multiple definition of `JLBFont::JLBFont(JGE*, char const*, int, bool)'
main.o:main.cpp:(.text+0x0): first defined here
JGE/JGE.o: In function `JLBFont::JLBFont(JGE*, char const*, int, bool)':
JGE.cpp:(.text+0x2878): multiple definition of `JLBFont::JLBFont(JGE*, char const*, int, bool)'
main.o:main.cpp:(.text+0x1e4): first defined here
JGE/JGE.o: In function `JLBFont::~JLBFont()':
JGE.cpp:(.text+0x2a5c): multiple definition of `JLBFont::~JLBFont()'
main.o:main.cpp:(.text+0x3c8): first defined here
JGE/JGE.o: In function `JLBFont::~JLBFont()':
JGE.cpp:(.text+0x2ab4): multiple definition of `JLBFont::~JLBFont()'
main.o:main.cpp:(.text+0x420): first defined here
JGE/JGE.o: In function `JLBFont::GetStringWidth(char const*) const':
JGE.cpp:(.text+0x2b0c): multiple definition of `JLBFont::GetStringWidth(char const*) const'
main.o:main.cpp:(.text+0x478): first defined here
JGE/JGE.o: In function `JLBFont::DrawString(char const*, float, float, int)':
JGE.cpp:(.text+0x2b60): multiple definition of `JLBFont::DrawString(char const*, float, float, int)'
main.o:main.cpp:(.text+0x4cc): first defined here
JGE/JGE.o: In function `JLBFont::printf(float, float, char const*, ...)':
JGE.cpp:(.text+0x2d00): multiple definition of `JLBFont::printf(float, float, char const*, ...)'
main.o:main.cpp:(.text+0x66c): first defined here
JGE/JGE.o: In function `JLBFont::SetColor(unsigned short)':
JGE.cpp:(.text+0x2d88): multiple definition of `JLBFont::SetColor(unsigned short)'
main.o:main.cpp:(.text+0x6f4): first defined here
JGE/JGE.o: In function `JLBFont::SetBlendMode(int)':
JGE.cpp:(.text+0x2d9c): multiple definition of `JLBFont::SetBlendMode(int)'
main.o:main.cpp:(.text+0x708): first defined here
collect2: ld returned 1 exit status
make.exe: *** [PSPopups.elf] Error 1

Execution terminated
thats the raw output, but it wont let me select all of the parsed error log, but heres a small part:

Code: Select all

 C:\Documents and Settings\Owner\Desktop\Popups\Menu.o In function `JLBFont::JLBFont(JGE*, char const*, int, bool)': 
(.text+0x0) C:\Documents and Settings\Owner\Desktop\Popups\Menu.cpp multiple definition of `JLBFont::JLBFont(JGE*, char const*, int, bool)' 
(.text+0x0) C:\Documents and Settings\Owner\Desktop\Popups\main.o:main.cpp first defined here 
 C:\Documents and Settings\Owner\Desktop\Popups\Menu.o In function `JLBFont::JLBFont(JGE*, char const*, int, bool)': 
and basicly one of those for every member function of JLBFont.

Heres what i got to call and use the fonts:

Code: Select all

//in Menu.h:

#include "JGE/JLBFont.cpp"

class Menu:	public JGE
{
...
public:
    JLBFont* mFont;
...
}

//in Menu.cpp:
//in Menu::Create():
mFont = new JLBFont(this, "Res/08underground", 16, true);

//in Menu:Render():
mFont->DrawString("hello world", 10, 10, JGETEXT_LEFT);	
Im not including anything twice, i dont know why its saying that.

UPDATE: Ive managed to reduce the amount of errors from around 27 to 19 by removing Main.o from my objects in my makefile. Ive updated the above errors with the new ones.
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

Post by dr_watson »

this line here:
#include "JGE/JLBFont.cpp"

what you should really put:

#include "JGE/JLBFont.h"

when you include "JGE/JGE.o" in your makefile, you don't need to include any of the ".cpp" file from "JGE/" folder.
Last edited by dr_watson on Sun Dec 11, 2005 11:58 am, edited 1 time in total.
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

That didnt fix anything :-\

But it did let me put Main.o back into my makefile without any extra errors :P
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

Post by dr_watson »

can you show me your main.cpp as well?
or maybe upload your project to somewhere and give me a link so I can checkout the entire project for you?
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

EDIT:nvm.. ill upload it, one second.
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

Post by dr_watson »

in your makefile, you have:

OBJS = Main.o JGE/JGE.o main.o

one of them supposed to be "Menu.o"?

if so, you should change your line in main.cpp:

from
#include "Menu.cpp"

to
#include "Menu.h"

Also, remember to do a "make clean" ;)
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

:D it compiles fine now! Thanks!

But now i cant seem to get the alpha channel saved in the .TGA image, its just a blank white image, even when i save it as 32 bit. Is there another version of this font maker that can save directly as a .png with alpha?

And also im getting this:

Image

It looks like its getting the width and height right, but starting too high.
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

Post by dr_watson »

Just specify a larger number as the font height ;)

As for transparency in PNG, I think Photoshop can save PNG with alpha channel?

Paint Shop can make one of the color as transparent color when doing a PNG export.
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

YES!!! I got it!! Thx so much!

Idk how i did it, but i got the alpha channel out of the .tga into a .png with photoshop by messing around with the channels :P
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Hey dr_watson, i think a great way to get ppl to use your engine would be to submit it to pspupdates along with a little description! Email pspupdates@contentholdings.com to do that.

I just love this engine and i dont like that not many ppl are using it.
Wraggster
Posts: 121
Joined: Fri Aug 26, 2005 7:40 am
Contact:

Post by Wraggster »

the whole scene watches these forums, i dont think he needs to email pspupdates, good newsposters search for news, this is by far the best place to get his work noticed.
Webmaster of http://www.dcemu.co.uk

DCEMU The Worlds Only Homebrew & Gaming Network of Sites.
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

It still wouldnt hurt to submit it.
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

It would also be a mistake to assume or imply that no-one is using the engine just because no projects have yet been publicly announced. :)
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

...you got me there... :)
dr_watson
Posts: 42
Joined: Mon Nov 28, 2005 11:30 am

Post by dr_watson »

Thanks seventoes!

Thanks Wraggster too! He posted a news item for me on dcemu forum!

In fact pspupdates post a news for me not long after I post here in this forum as well :). Later on I did a post in their psp development forum.

I think the entire PSP homebrew scene is still relatively small. News spreads pretty fast!
XRS
Posts: 32
Joined: Sun May 15, 2005 7:09 pm

Post by XRS »

I'm new to this and seems I can't compile this project.
This is what I get.

Code: Select all

psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall  -I. -I/usr/local/
pspdev/psp/sdk/include -O2 -G0 -Wall  -fno-exceptions -fno-rtti -D_PSP_FW_VERSIO
N=150   -c -o ../JGE/JGE.o ../JGE/JGE.cpp
../JGE/JGfx.cpp: In member function 'void JGE_Gfx::Gfx_ScreenShot(const char*)':

../JGE/JGfx.cpp:441: error: invalid conversion from 'int*' to 'int'
../JGE/JGfx.cpp:441: error:   initializing argument 4 of 'int sceDisplayGetFrame
Buf(void**, int*, int*, int)'
make: *** [../JGE/JGE.o] Error 1
What could be?
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

XRS wrote:I'm new to this and seems I can't compile this project.
This is what I get.

Code: Select all

psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall  -I. -I/usr/local/
pspdev/psp/sdk/include -O2 -G0 -Wall  -fno-exceptions -fno-rtti -D_PSP_FW_VERSIO
N=150   -c -o ../JGE/JGE.o ../JGE/JGE.cpp
../JGE/JGfx.cpp: In member function 'void JGE_Gfx::Gfx_ScreenShot(const char*)':

../JGE/JGfx.cpp:441: error: invalid conversion from 'int*' to 'int'
../JGE/JGfx.cpp:441: error:   initializing argument 4 of 'int sceDisplayGetFrame
Buf(void**, int*, int*, int)'
make: *** [../JGE/JGE.o] Error 1
What could be?
Looks like your psp set of libraries (psptoolchain or whatever it is called) is out of date.
CpuWhiz
Posts: 42
Joined: Mon Jun 04, 2007 1:30 am

Post by CpuWhiz »

@willow :--) - I think it's you who has the out-dated libraries, check the latest pspsdk and they changed this.

It seems dr_watson is using a somewhat stale copy of the toolchain for things. Anyway, I got this working with the latest toolchain (I recompiled the toolchain today, so I know it's recent) and working for 3.xx firmware (why everyone feels the need to use 1.5 I will never understand). I got rid of the exception handler as it was the only thing needing kernel mode and if the game doesn't crash, you don't need it (didn't feel like fixing it) ^^

d6237ddeeac1570a65a6eefeb4dd86f8 JGE_StarBugz_Src_v001_fw3xx.zip
f651e61b0d2e1c0193464d41c301bfe2 StarBugz_v001_fw3xx.zip
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

Oh but wait, Starbugz is made for JGE 0.2, which is seriously outdated (see the date of Dr_Watson's post)

I've encountered the exact same problem a few months ago while trying to compile JGE 1.0 with and old psp toolchain... so I assumed the problem was the same as mine, but it was actually the opposite : old JGE library With new tooolchain.

Edit : I should try to update my toolchain though... but I remember doing it less than 4 months ago... I should probably finish my current projects before updating.
Post Reply