PDA

View Full Version : Lemmings Remake



EricLang
18-09-2006, 10:46 AM
Hi GameProgrammers. this is my first post here...

I created a Dos Lemmings Clone for Windows.
There are clones for "Original Lemmings" and "Oh No More Lemmings"

http://home.hccnet.nl/ericenzwaan/lemmix/lemmix.htm

Now I have a few questions:

The game is written in windowed mode and does not make use of DirectX, OpenGL or whatever is out there. Just plain windows programming. (It makes use of the Graphics32 units to render the bitmaps, which is going very well.)
Is it possible to enhance the screenoutput used by Windows? (Scrolling is ugly when there are lots of vertical things).
If not then how can I port the screenoutput the easiest way, using DirectX?

I tried compiling DelphiX but this does not work for Delphi7, and seems rather old (or isn't it?).

The original gamescreen runs in 320x200. With the current generation of pixel-monitors it is not possible anymore to really set a resolution: it has to emulated. I can't use that for the Lemmings game. Is there a way to check the monitors pixelsizes?

Well that's it for now.
Bye, Eric

cairnswm
18-09-2006, 11:52 AM
There is a version of DelphiX that will compile under Delphi7 - just do a few searches and you should find it quite easily - There used to be a link to it from the Turbo site....

Is your source code available anywhere for us to have a look at. I'd like to suggest using SDL for the graphics but would need to see how your calls are working to know if its the best way to do it.

EricLang
18-09-2006, 12:15 PM
Ok. I just found the new DelphiX. I'll have my first look at it...
The source code will be available in the near future. working at it...
Most display is handled by one of the GraphicEx Components, which is (I think) one of the fastest ways to do in just plain windowed mode.

jdarling
18-09-2006, 01:11 PM
Look into SDL and S2DL as well. With those you can create an SDL window of a specific size. Also if your running in OpenGL mode you can easily setup scaling to 2.0 and have your rendering surface at 320x240 with your display surface at 640x480.

As for DirectX components, Dan JetX, Asphere, Omega, and many more exist. The latest version of DelphiX is pretty much unDelphiX .7 if I remember properly. Search the forums here and you can find the home page/download link. .8 is supposed to be out some time soon (at least according to the post).

EricLang
18-09-2006, 05:21 PM
I'm really quite new to this all.
What do you mean with "... is pretty much unDelphiX"?

jdarling
18-09-2006, 09:01 PM
I'm really quite new to this all.
What do you mean with "... is pretty much unDelphiX"?

Well, unDelphiX came about because people wanted an updated version. According to the EULA of DelphiX they made copies and re-built to use the same interfaces. So most if not all DelphiX applications will compile with unDelphiX.

WILL
19-09-2006, 02:33 AM
Nice job! :)

I enjoyed playing the original on the PC back in the day. Any plans to enhance or do some new things with your game?


I'm really quite new to this all.
What do you mean with "... is pretty much unDelphiX"?

UnDelphiX is the continuation of the abandoned 'DelphiX' project that as you probably know by now is a set of VCL components for Delphi that use DirectX for graphics, game control devices, networking and sound.

DelphiX is vastly out of date where it has been taken and updated, optimized and enhanced to become what UnDelphiX is today. Such things as hardware acceleration (hardware driven effects like rotation, scaling and alpha blending), using DirectX 9, general speed improvements, better use of memory, availability to later versions of the Delphi compiler (was originally restricted to Delphi 5) and a few other things.

Long text blurb made short, it's the version of it you'd want if you're going the DirectX/beginner's route. ;)


Of course Jeremy also mentioned SDL, which is another great graphics medium (cross-platform too). If you go that route take a look at JEDI-SDL (http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME). (Top dog of the SDL libraries for all Pascal compilers) Functionality it pretty straight forward, especially if you've been coding the graphics without VCL up until now anyways. :)

EricLang
19-09-2006, 06:23 AM
I certainly have plans to enhance the Lemmings.
As you can see there is already:
て「 recording and replay
て「 gradient bridges
て「 fastforward
て「 10 second game-jump
て「 savestate (enter) and restorestate (backspace)

At a certain moment I will leave the clone alone (that was the first purpose of my project: playing the game without dosbox) and create more things like cool graphic effects, new terrains and objects etc.

I installed DelphiX 1.07 into my Delphi7 Pro version now.

WILL
19-09-2006, 04:43 PM
Well personally, I'd love to play this on Linux when I eventually move over to it. :)

Great work non-the-less, it's one of thsoe classics that helped define intuitive gameplay as we know it today.

Any chance for new types of Lemmix guys? :D Or will we see ones from other later versions than the original? That'd be cool. I always thought the grapple gun guy was cool.

:idea:(I always thought it would be really neat to have a small goblin that stands maybe a few pixels taller than all the lemmings that would eat/kill them as they got close enough, but if you had a warrior/knight lemming you could fight them and make a path for your lemming buddies. :D ...ok got my idea out, I can breath now. :lol:)

EricLang
20-09-2006, 05:16 AM
Other lemming characters and further enhancements are on my list...

EricLang
20-09-2006, 07:48 PM
Now can anybody help me a little with DirectXLemmings?

I installed DelphiX 1.07 and managed to display a bitmap on the DDraw Component.

Now all my rendering is done internally with TBitmap32 of the Graphics32 library. So when referring to bitmap I mean TBitmap32...

I have bitmaps for
1) the world (which is adjusted when lemmings are bashing, digging etc.)
2) all lemmings animations
3) all object animations
4) drawbitmap, which is a copy of world

Could I just do the following every frame?
1) erase lemmings and objectanimations from drawbitmap
2) updategame()
3) draw lemmings and objectanimations to drawbitmap
4) flip this drawbitmap SOMEHOW FAST to the screen.

Steps 1-3 are really very fast (thousands of frames per second)

So the basic question is: can I draw this TBitmap32 fast to the screen, adjust it and draw it fast to the screen again?

Thanks, Eric

Traveler
20-09-2006, 07:56 PM
Quite exceptional work. I remember playing this game a lot when I was younger. Actually, now that I think of it, that must be like over 15 years ago. :shock: It sure does brings back some nice memories, though. Hehe, I can still see my dad play those levels again and again. He was quite good at it actually. I never got that far, but he just couldn't stop. Heh, those where the days...

Anway, I really like your version. It's pretty much a duplicate of the origional. I do remember the music being a bit different though. Iirc the tunes are the same, it just sounds a bit different. Could be my memory playing tricks though.

There was one odd thing while playing through ohno more lemmings.
http://upload4.postimage.org/1194781/lemmix.jpg (http://upload4.postimage.org/1194781/photo_hosting.html)
As you can see in the screenshot, I used one digger, but instead of going through one floorlayer, it took a portion of the wall too. I can't be too sure if that is in the origional game as well, but I don't think that should be happening.

Anyway, its just a minor thing in an otherwise great piece of work.

And just as a sidenote: thank you for making me remind of times past. I know it may sound stupid, but life is going pretty fast these days. I believe it is a good idea to look back from time to time, to see where we are in life. Your remake kind of helped me do just that ;)

EricLang
20-09-2006, 08:22 PM
Thanks Traveler...
Now for your "digging" question. I had some help from a lemming-guru. So the game-mechanics are exactly as the original. Even some slight differences between "lemmings" and "ohno more lemmings" are built in. You can check with the original and dosbox.

Now for my questions.... ?

czar
20-09-2006, 08:52 PM
That is so cool.

I almost feel like it might be a hoax and in fact you are running the original :)

Very well done. I would love to see a higher resolution version.

Love to have a look at the code too.

excellent work.

czar
20-09-2006, 08:58 PM
Just reading some of your questions.

When using delphiX you could port your work quite easily.

The individual Tbitmaps32s would be images in the dximagelist.

You do not need to erase individual element to achieve animation. At the start of every frame the entire screen is blank and you build all the elements onto the screen. i.e. each frame you draw all the walls and particles and lemmings. This is done so quickly that it feels like the objects are animated.

Which sounds like what you are proposing to do.

I am surpised you managed all this with graphics32 I found graphics32 good but of limited use and quite a pain to maintain.

WILL
20-09-2006, 09:58 PM
Very well done. I would love to see a higher resolution version.

You know Eric, it might be possible to enlist the help of a graphics guy here on PGD aswell. This site is primarily for programmers, but we get a good few artists and musicians here aswell. ;)


As for you question; This is what I normally do in all my 2D games:

NOTE: graphics engines have changed often, but the basic procedure remains the same!

-- Beforehand --
i) create my sprite and animation textures (many methods are acceptible, but keeping all frames of each animation sequence within the same single texture will speed things up drastically)
ii) create a virtual screen to draw on before sending it to video memeory
-- Begin Loop --
1) Clear the screen OR draw panaramic/background layer(s) (if I have any)
2) draw sprites/objects & tiles (may consist of multiple layers and any number of tile layers and object layers and special effects/particles)
3) Draw any forground graphics you want to pretty things up with.
4) Take the virtual screen memory and flip it into the video memory. (Minimize on going from system memory to video memory because this slows down graphics the most!)
-- End Loop --

REMEMBER to deinitialize all allocated memory (read a lot about memory leaks? now you know where. ;))

JernejL
20-09-2006, 10:30 PM
sorry to interrupting: for all interested into history of lemmings:
http://www.dmadesign.org/Lem_1.htm

also see http://www.dmadesign.org/ for more history about the lemmings makers:
http://www.dmadesign.org/

EricLang
21-09-2006, 02:34 AM
Ok Thanks you all so far.
Now for WILL's answer...

My main problem seems to be that DelphiX (which I am going to try for a while. It seems the best way to start of...) uses this TPicture in it's TDXImageList. How do I get the TBitmap32 in there without assigning (which means moving too much memory around)?

-----------

There is a lemmingsgame in higher resolution, written in java. It's called Lemmini (http://lemmini.de/).
And also WinLemmings has higher resolution, but unfortunately this is not a very good remake in my opinion (bugs, sluggy mouse reaction, worse game-mechanics). Lemmini is better.

------------

As for the music and sounds in my remake: the musics are mod-files from the amiga version (it seems impossible to hack adlib.dat, which contains soundblaster emulation data I think) . The sounds I borrowed from the winlemmings version. Sounds will change a bit. That's still in progress. I think I am going to use the amiga sounds as well.
So the "cloning" of sounds is not 100% possible I think.

WILL
22-09-2006, 05:22 PM
My main problem seems to be that DelphiX (which I am going to try for a while. It seems the best way to start of...) uses this TPicture in it's TDXImageList. How do I get the TBitmap32 in there without assigning (which means moving too much memory around)?

If my memory serves me right --it's been a good few years since I've used UnDelphiX-- you are looking for the draw function in the Help files. It is a method of the TImage object that references the 'Screen' that you wish to draw the image to.

The older DelphiX used to have an installation that setup the included help files in with your standard Help files so searching through them would be the same. Now you have to manually do this, if that is what you want.

Look the help files in the UnDelphiX folder and have a good look through them. You should specifically look for at least the drawing functions, how to fill a TDXScreen, Flip it and how to dynamically load and free images.

That should cover your basics. Sound should not differ much, I think. It's been some time since I've used the suite.

EricLang
09-08-2007, 04:24 PM
Restarted the clone project. It will be further expanded.
I want to make the graphic output optional: using Graphics32, OpenGL or DirectX.

Two questions:
1) How can I handle this?
2) What is the best place to handle input (mouse, keyboard).

I'm really stuck a bit. need some advice:)

And I really need a good example of OpenGL 2D animation.

Momor
09-08-2007, 08:49 PM
I would suggest to create a graphic functions unit for your project, where you will define all the graphics functions & structures that you will need:

- Initialize window/video mode function
- LoadImage function
- RenderImage(x,y)
- and so on ...

Is it important that you only use the functions & structures of this unit to make all the graphics operations of your game.

Then, you will be able to code your game using this "abstract" layer. You can first create the Graphics32 implementation of the unit, and if you want to create an OpenGL renderer you will have to write specific versions of the functions only - no impact on your game.

About input handling, it may mostly rely on the libraries you plan to use - Win32, SDL, VCL manage events in their own way.

Dunno if this is what you're looking for, but here's a tutorial about ortho projection in OpenGL : http://gpwiki.org/index.php/OpenGL:Tutorials:Tutorial_Framework:Ortho_and_Alph a (sorry it's in C, but it's the same in Pascal).

EricLang
09-08-2007, 09:22 PM
Ok thanks. The example of the sprites is not what I am looking for. I am looking for a simple example with:
1) a large background bitmap
2) with small sprite-bitmaps moving around.
Just flat stupid bitmaps running around.

And handling the input is more a general question:
The mouse/keyboard messages are usually catched by some window with a handle, but this window or displayscreen does not know what to do with the mouseclicks: in my opinion the game-engine is the entity that "knows" everything. I am having lots of that kind of OOP problems and always working on my own. Sometimes you go blind then :)

LP
09-08-2007, 11:35 PM
Restarted the clone project. It will be further expanded.
I want to make the graphic output optional: using Graphics32, OpenGL or DirectX.
Why do you need OpenGL and DirectX for? You won't be using hardware acceleration anyway. IMHO adding optional support to these is a waste of time.

I've played your game and it was pretty neat. Why do you want to start over?

EricLang
10-08-2007, 06:39 AM
First: The editor and the clone game do not make use of the same code. When making the clone I copied all code and changed/added a lot of things. I want to change that

Next: The next version will be able to edit terrains / objects, add new lemming-styles etc. etc. Also higher resolution will be possible.
The "lemming framework" has to be rewritten to support old styles AND new ones.

Now you get me really confused. I know the Windows API is extremely slow, when it comes to drawing to the screen. So I was actually hoping the DirectX / OpenGL would eliminate this problem. Why won't the game be using hardware acceleration? (I'm an almost complete Noob to OpenGL and DirectX).

With the Graphics32 (TImage32) I use the "Dirty Pixels" scheme. Erase animations - process mechanics - Draw animations. That's why it has an acceptable speed.

User137
10-08-2007, 07:03 AM
I wonder.. maybe TImage with TBitmap's as sprite and back buffers would be sufficient for this. Because back buffer only needs to be 320x240, then set TImage property stretched to make it feel the nostalgy :)
SDL may be good choice (never used myself), where OpenGL and DirectX suffer in speed if you need to manipulate texture pixels on fly. Ofc if you have levels made of small elements/grid then manipulating isn't necessary.

Edit: API isn't slow. Like said before, use buffers: Draw everything in memory, then draw it all in 1 call to screen. That's what OpenGL and DirectX does.

EricLang
10-08-2007, 07:21 AM
in "Window API" mode my dirty pixels scheme is needed, otherwise i even can't make the needed speed in some cases!
So API is slow. Very slow.
I am drawing everything to a virtualscreen first. But the BitBlt function just is not fast enough. That's why I only update the screen where needed.

BTW: Stretching the bitmap with graphics32 is faster than stretching it "onscreen". So I stretch in the virtual screen and then graphics32 uses bitblt.

But when I draw my virtualscreen in OpenGL / DirectX and then use some "Flip" method. Isnt that much much faster than in normal windowed mode??
Because that is what I want.

User137
10-08-2007, 09:32 AM
in "Window API" mode my dirty pixels scheme is needed, otherwise i even can't make the needed speed in some cases!
When it comes to hardware acceleration, you see all textures are stored in 3D card memory. Loading them in is slow process, especially if you have destructible large map that does it all the time, even every frame. In my game experiments it really slow it down.

But it is possible for even OpenGL with certain optimizations:
- Split map into smaller pieces, like 64x64
- Store pieces in raw data format that are in directly loadable into graphics card (RGBA bytes for example)
- Keep track on which piece needs updating and skip rest
- Have update delay, maybe every 3rd frame
(These things helped me to have destructible maps of very large size, even 3000x3000)

But because of this complexity i'd still suggest unDelphiX or other 2D engine for task they are made to :P Hardware acceleration really shines in 3D, blending effects, rotating etc.

EricLang
10-08-2007, 10:04 AM
I almost can't believe what I am reading :)
I thought graphics were insanely fast these days.
I seriously need to go and study this things.

In fact: The repaintoptimizer of Graphics32 splits up the map in 32x32 pieces. The only replacement I need then is using some RefreshInvalidRects method instead of the default BitBlt

User137
10-08-2007, 01:10 PM
They are insanely fast with triangles and polygons generated of them but when it comes to single pixels it's "oldschool" and unsupported tech 8) Pixel shaders although are a different case i haven't studied, my old Radeon 9200 can't even display them.

LP
10-08-2007, 03:30 PM
Now you get me really confused. I know the Windows API is extremely slow, when it comes to drawing to the screen.
Define "slow"? Actually, I think Windows API is quite fast and efficient. Are you sure that your performance bottleneck is API itself and not your code?

If I were you, I would store the game pixel map in a large bitmap; when drawing on the screen, I would draw only subset of such bitmap. For modifying map, I would simply get direct access to all pixels and modify them once per frame. You won't get 500 FPS this way, but for what you need it's one of the best approaches.

EricLang
10-08-2007, 04:03 PM
No it's not my code. Thanks to the very smart RepaintOptimizer of Graphics32 the program is allright.
But look what happens when scrolling left or right: then we are forced to update a whole screen. Especially when having vertical structures you can see it is not smooth at all.
Anyway I am getting quite desperate. How on earth can Blizzard make smooth scrolling in World of Warcraft :)

LP
10-08-2007, 05:26 PM
As it has already been suggested, use back buffers to enable flickerless scrolling. Also, you heavily rely on Graphics32, which might not be a good thing.