Qbasicnews.com

Full Version: REL's pixel scrolling engine ported to FB!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Yup, I did it! Finally something useful from me. This was actually done two weeks ago but I wasn't able to upload it till today.

The engine features:
* pixel by pixel scrolling using GFXLib 2 graphic statements
* engine compatible with GFXLib screen modes from mode 11 to mode 21
* PUT(PP256 file format) file loader
* pixel perfect collision with moving NPCs
* PP256 custom font printing routines(ported to FB!)
* map file loader
* engine packed in a nice demo(20*20 pixels large tiles)
* two compiled sources(one in screen mode 13 and one in screen mode 18)


Download the engine here: http://kentauri.digitalblackie.com/FBscrollEd1.zip

Screenshots:
http://kentauri.digitalblackie.com/scrollhi.gif
http://kentauri.digitalblackie.com/scrolllow.gif

If you are not familiar with the original engine I'm talking about Richard Eric Lope's pixel by pixel scrolling engine made in QBasic with RelLib. Eric created it to show the powers of the mentioned library. The very engine helped me in the beginnings and it was the backbone of my several games, like Dark Quest or Ball Blazing Fantasy. I also released a couple of "advance" versions of the engine, mainly with game design oriented additions.

This was not the only reason why I wanted to port it to FreeBASIC. I've notice quite few people, including me, having problem switching to FB so to help myself and others I decide to port this lovely engine and heavily comment it. It uses GFXLib 2 graphic statements and Eric's FB PUT file loader(Pixel Plus 256 standard file format). You can create any kind of ZELDA style game in it, from an action game to a RPG.

Not much porting was needed to be done so this is mainly Richard Eric Lope's peace of work. I just felt that community would benefit from something more user-friendly than Space Impakto source code. So this engine is also a very useful GFXLib 2 example program and anyone who wants to create a game in FB and doesn't know where to start should take a look at this. Like I said before, the engine is heavily commented, very easy to understand and modify for his/her game design needs.

It's not perfect so this is what might come in the next versions and I could use(from you):
* sprite translucency(the latest version of GFXLib 2 probably already features it)
* BMP to PUT converter(FB compilable, QB one already exists)
* different type of sprite/tile loading(do you have some sort of routine?)
* different custom font printing routine(s)
* larger tiles and sprites suitable for screen modes like mode 18(40*40 pixels large tiles)
* different map loader compatible with some map maker(do you know any?)
* milisecond perfect delay routine(independent of external libraries)
* more features in the engine demo, game design related(to help newbies)

Known bugs in the engine:

Pixel perfect collision with moving NPCs is not the best but I doubt it can be improved much. Anyway, the collision routine is meant to work with a different type of collision(projectile collision or similar; action game related).
Strange tremble(delay in screen refreshing). I'm pretty sure this is a bug in the very GFXLib 2 or a problem with video card compatibility. If I put WAIT &h3DA, 8 before SCREENCOPY in my main loop I get a lot of this tremble. On the other hand, if I put WAIT &h3DA, 8 after SCREENCOPY in the main loop the tremble is almost ignorable. Please, send me your thoughts on this.

The engine is not meant to OpenGL freaks and people who dream of creating his/her own version of EverQuest. The scrolling engine was created for to people who are interested in old-school game design, what most QBasic game designers used to be, or still are.

Why should you desing 2D, 256 colors games in FreeBASIC when you can do it all in QBasic, you might ask yourself. Well, here are the benefits of working in FreeBASIC:
* you programs will be 32-bit compatible
* goodbye 64Kb memory limit; no more memory related problems; create huge maps, huge tiles and sprites, complex worlds, add layers and layers of stuff, create wild cinematics
* super-easy way of adding sound and music to your programs with FMOD
* you can ship your program/game with Linux and Windows compiled run file
* and all the other things that FreeBASIC has to offer and QBasic doesn't

Don't worry about the engine speed. It's around 70 FPS because of the WAIT &h3DA, 8 statement. Try to REM it and enjoy in 2000+ FPS. GFXLib 2 emulation of the QBasic WAIT statement doesn't seem to be useful for anything other than to nicely slow down your program in FB. So if I find or if someone decides to code a nice FB ASM millisecond delayer usage of WAIT statement will become obsolete. Me thinks. Maybe I'm wrong. I dunno.

One notable problem. In Pixel Plus you can't create a PUT file larger than 64Kb. I'll try to find PP256 source code to change this. Not a huge problem but if you decide to work with large tiles working in PP256 won't be much more convinient from capturing tiles saved in BMP or GIF images.

I'm opened to all the suggestion, critics, changes and additions to my engine. Especially from Eric and lillo. Tell me what is wrong with the engine and can be improved.
56 people saw this thread and nobody has a single comment. Nobody has help to offer. Oh well.
heh I could never get back onto thse forum. Dunno if this is happening to anyone else, but it seems I can only get the page to load at random times. :???:

Anyways, these are great examples, and the easy to use .bi files will certainly come in handy. I'll definitely benefit from them once I'm out of this text mode kick I'm on. 8)
Runs very smoothly here (in windowed mode at least; in fullscreen it was a bit jerky occasionally)... I did manage to get stuck on another character for a few seconds, but beyond that, everything worked well. You might want to consider compiling with -s gui. One other thing (I don't know if you wrote this part of the code or if relsoft or Chris did) - there is a routine called GetDepth, which is confusing, since 'depth' in this context usually means color depth, or bits per pixel, rather than height, as it seems to mean as used here. All in all, good work - I hope to see some completed games using this someday. Smile
I'll change GetDepth to GetHeight in the next version of the engine.

What -s gui command actually does? I didn't took time to study FB command line parameters.

As I said for the collision in the doc it's not really suitable for that kind of collision. But maybe you can tweak it. The very collision if perfect. The problem is what you do(which variables you change) when collision happens and how.
-s gui on win32 keeps a console window from being created.
Perhaps this is because I'm new to Freebasic, but I have some questions about compiling scrollingengine13.bas. I'm using FBIde with Freebasic 0.14b stable for Win32.

I get many errors (no. 42) about undeclared variables. After going through and manually declaring everything, that goes away, and I finally get to this:

Line 938, Error 21, type mismatch, found: ')'

Code:
GetWidth = (@Tilem.s_image.p_data[Tilem.s_image.p_dataindex[ImNo+1]] \ 8)-(@Tilem.s_image.p_data[Tilem.s_image.p_dataindex[ImNo]] \ 8)

As far as I can tell, there is no type mismatch going on here, and parentheses are correct. I checked all places where GetWidth is called, and the variable types being sent are correct, as well as that of the variable being received to.

Any ideas?

Anonymous

change getwidth function to this:

Code:
FUNCTION GetWidth (ImNo,tilem as tileType)
' Function used to acquire width of a character sprite
' (due the R.E.Lope's method used to store and display sprites
' on the screen I have to use this lame way to get the sprite
' depth). This code is pending for correction.
' Only one error can appear with this sub; if you use the last
' character from your font set. So just create one image behind your
' last character in the font set in PP256 of any size(ie, 1*1).

  Dim As Integer temp1 = CInt(@Tilem.s_image.p_data[Tilem.s_image.p_dataindex[ImNo+1]]), temp2 = CInt(@Tilem.s_image.p_data[Tilem.s_image.p_dataindex[ImNo]])
  

    GetWidth = temp1 \ 8 - temp2 \ 8

END FUNCTION
Quote:change getwidth function to this:

Many thanks, Cha0s!
I've update the Edition #1 or the scrolling engine with a fix. The problem with GetWidth function and new version of FB has been fixed. 100% CPU usage problem has been avoided by adding a SLEEP 2 statement in the game loop. The collision with NPCs has been slightly improved. The source codes have been recompiled in the latest version of FB(ver.0.14) so the speed and the quality of scrolling is slightly better now.

You can download the fixed Edition #1 from the same URL: http://kentauri.digitalblackie.com/FBscrollEd1.zip

I apologize for all the problems that the previous version may have caused.

Support for 24-bit or higher graphics is being planned. As soon as I get some code from Eric. Wink
Pages: 1 2