Lemmings Forums

Lemmings Boards => Tech & Research => Topic started by: oskar12345 on March 13, 2014, 08:08:50 PM

Title: Lemmings in C#
Post by: oskar12345 on March 13, 2014, 08:08:50 PM
I'm working on a Lemmings version in c#and i need help from someone to design animations,code help, etc. i'm noob in c#
I have all the sprites and levels and i'd like to work on mechanics and logic engine. I do this for practice c#

<a href="http://youtu.be/kK2PKpe2m9M" class="bbc_link" target="_blank">http://youtu.be/kK2PKpe2m9M</a>
Title: Re: Lemmings in C#
Post by: LJLPM on March 27, 2014, 11:32:43 PM
Well, have you made some progress on your project?
What is the format of your levels? (a single image for a whole level, or are the levels tile-based, which is the way Lemmings works)
About the game logic, you will have to loop through a list of Lemmings and update their behaviour depending on the task they were assigned to perform: so, in your Lemmings class, you'll need to store the x,y position of a Lemming, its walking direction, its current action, its alive/dead state, its current fall height (may be 0, when walking), its floater/no_floater state... well, everything you would find useful to make a Lemming walk, fall, die, etc...
About the collisions: you can first try to test the x,y position of your Lemmings against the blue color of your level's background (as seen in your video). If you detect the background's blue color at a Lemming's x,y feet-position, then update your Lemming's y position to make it fall, until you no longer detect this blue color (which means your Lemming has reached the ground). About wall-collisions, well, check the color ahead of your walking Lemming (is it blue or not?).
Later, you may want to create a separated image-mask of your level, in order to detect special objects or steel (for example, your mask may be mainly in black&white, and you would use another color to code the steel pieces)
Title: Re: Lemmings in C#
Post by: mobius on March 29, 2014, 04:19:47 PM
aw shame you chose C# as I just begun learning C++. If I could help I would try but I can't tell you how long it will take me to learn it. I'm a quick learner but my motivation is very poor.

Here is a topic that may help you;
http://www.lemmingsforums.com/index.php?topic=569.0

Simon made the program lix, in C++, but some of the things there might be helpful anyway. Lemmings is a game prone to an infinite amount of glitches.

will this program be for the computer if it's finished? -Those Lemming graphics look good so far  :)
Title: Re: Lemmings in C#
Post by: LJLPM on March 31, 2014, 10:18:18 AM
Your video shows a nice animated sprite working with perfect collisions. Having a lot of Lemmings is just a matter of looping through a list ; and now that you know how to handle collisions, then codings bashers, miners, and diggers will require you to simply draw the background's blue color over the actual landscape. If you really want to code a Lemmings-clone, you'll need a mask of your level for easily detecting the objects (collisions with traps, exit doors, 1-way arrows, ...).
Title: Re: Lemmings in C#
Post by: ccexplore on April 03, 2014, 10:35:22 PM
and make the mask like a copy in png,for example rose color for picture bits,grey for traps,red for steel,blue for water and let it open for future staffs.

Keep in mind that you may want some elements to overlap.  For example, exit and trap trigger areas typically overlap with some terrain pixels (though it doesn't have to be that way).  Supporting that would put some constraints into the scheme you use for the mask.

=====================

I was going to write something here about generally how the code for most games/simulations are typically structured conceptually, but I'm thinking you probably know the basic ideas anyway, I'm not too good a writer, and the internet likely has better written materials that can explain those concepts and ideas better than I ever could.  That said, if you do have any general or specific troubles with implementing the game logic I'm happy to try to help.  However, I'm also not that familiar with C# and more particularly with the libraries/APIs you may be using for things like graphics and sound, so for those kind of deeply technical things I may not be all that helpful unfortunately.  You can try researching the web for boards/forums that are more dedicated to that kind of questions.

Additional semirandom sidenote: in the original Lemmings game, in terms of game logic each lemming is effectively treated as a single pixel even though its graphics is of course larger than that.  One obvious motivation for that treatment is of course performance, as collision detection is much faster when you only need to check a few pixels.  But this also gives rise to the quirky aspect where a lemming can walk and fall through the narrowest of gaps, something which most longtime lemmings player have become quite accustomed to.  Of course there is nothing that says you have to follow this tradition, there are
Title: Re: Lemmings in C#
Post by: oskar12345 on March 17, 2015, 07:44:19 PM
GameName5.exe is the exe inside Debug.RAR,it's programed with c# in monogame-xna for this reason i think u need net framework to run it
if someone want the source code for me it's no problem to share,i'm really noob with c# and classes too. :lix-smile:

Exit, doors, traps, digger finish now
Can put sprites in any order u want
Trigger áreas are used like rectangle regions
Can put any picture as level

Monogame is cross-platform and can be ported to android,linux, etc. Easyly but i dont't know.
Title: Re: Lemmings in C#
Post by: Ben H on March 21, 2015, 12:53:07 PM
Nice.  :thumbsup:
Title: Re: Lemmings in C#
Post by: LJLPM on March 21, 2015, 11:00:32 PM
I tried your .exe: the result is very nice, and it's promising. Well done!
Title: Re: Lemmings in C#
Post by: EricLang on April 07, 2015, 11:26:41 AM
Nice! Where do the graphics come from?
Title: Re: Lemmings in C#
Post by: oskar12345 on April 13, 2015, 02:07:41 PM
beta 1 finished. i can´t upload it ,i don´t know why.it's 12mb size the exe and 100mb the graphics and styles.
Title: Re: Lemmings in C#
Post by: oskar12345 on May 13, 2015, 11:49:13 AM
https://mega.co.nz/#!zhE3RSRR!SF65Qtc577-4iv1J0stSAiyHtzFBhwl9zKcFqU3g6ps          Debug beta 1 Executable

https://mega.co.nz/#!y1NlEDyL!xl2yUO5hmVQwnqclLYsB_X5fdpGkW2sLJY_JOUKm_V0    objects one styles png
https://mega.co.nz/#!qtECEKxY!WELEMbKWO5Z7vpDtlL86d4Z-qQieKlbGadgaYH9pPXE   objects two styles png
https://mega.co.nz/#!b4VBwKoA!6WOKx6Zi9OlK8zW9qnvZfXFedGA3pvfcBpSjaOG7MtU  objects three styles png
https://mega.co.nz/#!zxdU1KQb!KmDKK9GOzD-4eoCpecMs0i3smL9228ekFQMqffp_lsI    objects four styles png
https://mega.co.nz/#!e1l1DQ6Y!URI-pEtWtpUUzx_rpXhL8IX96Nde3K9NJdGuuw6VJf0      Levels FUN 30 levels terrain
https://mega.co.nz/#!i4tzzaxR!26oTqRF6EZlrV8OErknoBUaBvM93bMu5NQ68koJc6mw     Levels TRI 30 levels terrain

There it is all the PsP styles and 60 levels and the exe of the beta 1. All skillls and more.
Title: Re: Lemmings in C#
Post by: LJLPM on May 13, 2015, 04:44:36 PM
just tried the beta1 executable: it's a good job, with nice visuals, indeed! Keep up the good work!
By the way, during the game, I noticed that you can't assign new skills to already-working Lemmings (diggers could be turned into bashers, and then could be turned into builders, and then...)
Title: Re: Lemmings in C#
Post by: oskar12345 on May 13, 2015, 05:56:47 PM
the skills works ok now,  i forget a few if variables...

from now the EXE size is 85 kb-> fun001.exe 85kb...fun002.exe 85kb...etc until 156 levels or whatever. All the exes shares the same content dir
i'm planning to do one exe for one level , it's so easy to code a diferent level with others graphics,traps,etc... only change a few lines

i don't know really good how to implement all in one only exe in c#
Title: Re: Lemmings in C#
Post by: namida on May 19, 2015, 07:02:26 PM
Are the levels hardcoded into the EXEs, or loaded from a file? And, does an EXE support restarting a level from the beginning, or would a player have to close and restart the EXE? If it's loaded from a file and restarting is supported, all you'd have to do is load a different level then restart, I'd imagine. Of course that's just one way of doing it, and you'd need some kind of menu to select a level (but this shouldn't be a very hard task).
Title: Re: Lemmings in C#
Post by: oskar12345 on May 20, 2015, 04:35:30 PM
i'll see to implement restarting, the problem is the xna-monogame method for initialize variables in the begin of the exe. i'm sure it'll be possible but i don´t know.
the levels loading are from the files no problem.

i'm finishing 60 more levels images and then upload all the graphics and the source code too.
i think i have to recode all the source,for me it's more easy to write one exe for any level i want.

then i'll try to translate it to android...
Title: Re: Lemmings in C#
Post by: namida on May 20, 2015, 04:37:32 PM
If it helps, you can get the Lemmix source code here. It can be a tad hard to follow; it's also written in Delphi rather than C# but if you have a decent amount of programming knowledge, you should be able to follow it. (I was able to understand some C# code mostly just based on my Delphi knowledge, at least to enough of an extent to work out how a program worked.) It might help you work out how stuff is done.

https://www.dropbox.com/s/i1gum9va0m7fr3z/PlayerSource_V28.zip

SuperLemmini and Lix are also open-source (SuperLemmini is Java and... not sure whether Lix is C or C++, but it's one of them), which may also be of help to you. NeoLemmix source can also be provided on request if you feel it'll help, though in terms of how it handles switching levels it's almost identical to regular Lemmix.
Title: Re: Lemmings in C#
Post by: Simon on May 21, 2015, 12:17:51 AM
With OOP, the first idea is to have the entire play in a large class, and reinstantiate the class. Since this is unwieldy, the next idea is to have savestates as components in the game class, and go back to a savestate from the very beginning.

-- Simon
Title: Re: Lemmings in C#
Post by: oskar12345 on May 22, 2015, 09:06:07 AM
i'm really noob with classes, i never used it. i need to study more... i understand the concepts but i need more practice..
i'll try to implement like dos only with ifs, conditions and structs that i initialize when  i change levels if it's possible

for this reason i'll upload the source code if someone can help.it'll be great.
Title: Re: Lemmings in C#
Post by: namida on May 22, 2015, 12:07:25 PM
It's well worth learning them. They're not overly difficult to use, and extremely powerful.
Title: Re: Lemmings in C#
Post by: Simon on May 22, 2015, 05:11:26 PM
I've skimmed the source.

You are already using a struct for the lemming. You can implement what I have suggested with all-public structs and normal functions. I.e., you don't need inheritance, you don't need virtual methods, ...

This is a general observation: A language is a toolbox, you don't need to use every tool.

For readable source, try to keep your identifier names in English. Comments in English are also preferred.

-- Simon
Title: Re: Lemmings in C#
Post by: oskar12345 on May 31, 2015, 06:13:13 PM
here it's the beta 2. All the levels on one exe
almost finish defining all traps drawing,background parallax,rectangles for logic,logic steels,arrows...etc.
All are in structs for future addings (level images,traps,new sprites,doors,exits,whatever), only have to code some lines on the source.

https://mega.co.nz/#!zgMSXB4Y!UdULyejRbZayXq3kXMTKqj3HoszOrKZs6er02MASoTM