Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: My Sonic the Hedgehog game (goes fine, but need help)  (Read 10893 times)

0 Members and 1 Guest are viewing this topic.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
My Sonic the Hedgehog game (goes fine, but need help)
« on: September 23, 2013, 07:06:18 am »
Hello, Ladies and Guys from SFML

I'm working on a Sonic the hedgehog game, cos I'm a fan of it, and Mario, since I was a child
By now, it works fine, has 4 Zones, 2 Acts each one, and has an interesting memory problem

Here's the link to download my poor Sonic (exe, dlls, and data files, in a .rar)
https://www.dropbox.com/s/9ikj1kbm53oqpp3/Sonic%20the%20Hedgehog%20by%20Pablito.rar

My system is Windows 7 Ultimate, 32 bit, and the program is written in C#

I would need to know these:
* Should I post a link to the source code? (I would have no problem)
* There's a problem in the app, it throws an Exception of the OutOfMemoryException class, when loading Zone3Act1; Is it allowded to ask help about that here? If it's not, please tell me where it is (I already asked in the Help->General, and nobody knew how to solve my bug); if it is, then I explain it below;

On each game level, the program calls the LoadZone?Act?() method, which loads 2 Images (.jpg that are there in the LEVELS subfolder), the level's foreground and background ... in some levels, by now the background is null ... the Images are local variables, that are passed to 2 Sprites[,] splitted into 1000x1000 Textures
First I built the Images in runtime, and saved them to files (Image.SaveToFile()) ... when the app runs with the 1st option, it works fine (excepting for a casual SEHException - that I don't know what it means), ... but when it loads the Images directly from the .jpg files, it throws a disgusting OutOfMemoryException when attempting to load Zone3Act1.jpg ... I don't know how much RAM my program needs, but my system has 2 GB, ... then I ran the game, starting on Zone3Act1, and it ran up to 4-1, where occured the same problem

I tried Image.Dispose(), Texture.Dispose(), etc, etc ..., reallocating the objects with "new" ...

Perhaps if you see the code, someone will find the bug ... there are many files, but those where the problem could be are 3 or 4, and they aren't too long

If it isn't the correct place to talk about this, I'm sorry, and please tell me where should I do
Thanks

Pablo
(Bs As Argentina)

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #1 on: September 23, 2013, 07:27:25 am »
I think I tested and posted in your prevous thread too, but your Sonic game still crashes on startup for me.

I have no experience with C# so I can't help any more directly, but you should definitely consider posting all of the source code, and posting a debug build of your game so people who know what they're doing can at least try to use a debugger on it.  It can't hurt.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #2 on: September 23, 2013, 11:40:54 am »
It's O.K., MiLord!

Here's the link to my poor Sonic's source code files
https://www.dropbox.com/s/tzts0sy3s6hswj4/SOURCE%20CODE.rar

These files just generates the executable, that needs the SFML DLLs and the DATA FILES folder to run
(if someone has difficulties in understanding the code, just inform, and I'll try to make it more legible, in all ways, such as longer variable names so they can be caught the idea what they are/do)

I think you (Ixrec) told me you were using Windows 8 64 bit ... I supose there must be a way to adapt a SFML app from 32 bit to 64 bit, I'll ckeck out, I think I remember that there is a SFML library version for both 32 and 64 bit ... but is it needed to recompile the program, or just copy the 64 bit DLLs to the folder where the exe is, to be able to run my game on a 64 bit system?

Maybe if you try to run my poor Sonic on a 32 bit system, it will run properly ...

Well:
* Please, if someone runs my program, tell me in what way it crashes
* If someone can help to solve my game's memory trouble, I will appreciate it very much
* So I will if you tell me how to adapt my poor game to different PCs, and OSs
* Welcome critics and suggestions to improve the app

The crash cause should be in the LEVEL subfolder files

Thanks!

Pablo

PS: I know very well I'll have to improve the graphics, and all the game; remember the power of each bubble/shield you can get from the TV items (the fire bubble impedes fire to hit your character, the magnetic one lets you jump higher)

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #3 on: September 23, 2013, 01:23:16 pm »
Same here, Windows8 64bit.

Error message in the cmd:
Quote
Unbehandelte Ausnahme: System.BadImageFormatException: Die Datei oder Assembly "
sfmlnet-graphics-2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" oder
eine Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei mit
einem falschen Format zu laden.
Dateiname: "sfmlnet-graphics-2, Version=0.0.0.0, Culture=neutral, PublicKeyToken
=null"
   bei SonicTheHedgehog.Program.Main()

Sadly I'm not able to change the language of this error message. But it says something like it can't load (Bad format) sfmlnet-graphics2 or one of it's dependencies.


I'm not used to C# but in c++ you can always open a 32bit application with a 64bit OS.



AlexAUT

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #4 on: September 23, 2013, 02:12:22 pm »
Maybe what was wrong was that I used the DLLs in the folder x86 from SFML.NET ... because my system is 32 bit, then in my PC it works
Now, I compiled a new copy of my program, with the DLLs that are in x64 folder ... (Oremos para que funcione en las PCs de 64 bit, en la mia de 32 NO lo hizo, quizas es una buena señal)

So, please, I invite those Ladies and Guys who have a 64 bit system to test my poor "Sonic 64 by Pablito" Version for 64 bit

https://www.dropbox.com/s/xm54luwk8wehynb/Sonic%2064%20bit%20by%20Pablito.rar

Then, we just were missing to solve the crash because of OutOfMemoryException,
from what I would appreciate your help,
Thank you

Superdude

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #5 on: September 23, 2013, 09:06:09 pm »
I select my player, then get a purple screen with:

Used memory: xxxxxxxxxxx

Is this an error?
The game does not continue after this.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #6 on: September 23, 2013, 09:38:33 pm »
Now the game starts.

Then i select a character (there you shouldn't use sf::Key::isKeyPressed or implement your own system on top of it, because I can't select the hero in the middle) then i get the same screen as Superdude described but my screen is blue  :o


AlexAUT

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #7 on: September 23, 2013, 10:12:48 pm »
Same for me, it does actually start up and play now.

I also get the blue Used Memory: xxxxxxx screen (the number's different every time) after character select, but to my surprise it actually gets through that and continues to the level after several seconds.  I played the whole first level plus boss and made it to the second level before writing this post (the Used Memory thing happens again between levels).

A few things had me very very confused for a while, but after a whole level it's clear to me that certain things simply aren't getting drawn.  In particular, some kind of trampoline or jump pad is invisible, and the first boss' attacks are all invisible.  You can imagine how confused I was by these at first.  I would say the movement and jumping physics feel extremely glitchy but I have no idea how much of that is caused by more invisible stuff.

Also, when I press Esc to try and quit, the game crashes.  Windows did not provide any useful error message for this crash.

By the way, I was under the impression that compiling for 32-bit windows made stuff work on both 32-bit and 64-bit systems.  Does anyone know of some strange property of C# or SFML.net that breaks this compatibility?

Sub

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #8 on: September 24, 2013, 12:19:06 am »
The first link you had crashed for me, second link work was slightly better.  I got to the point where you could select a character (which, btw, you need to put that on a delay, you almost instantly skip over the middle character) and then the game goes blue with a memory used message, at which point I alt tabbed and it crashed.  It seems to crash whenever I alt tab, actually.

The music was also way too loud, but maybe that's just me.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #9 on: September 24, 2013, 10:18:48 pm »
Hi Ladies and Guys

Now I fixed the Alt + Tab crashing issue, as you told me, I tested it myself;
Also I fixed the Esc pressing (To quit the app) matter, now if you press Esc you return to Start screen, where if you press Esc you exit ... ( It seems to me or we re missing a SFML QuitApplication function? )

Ixrec, you saw the springs (or jumping pads) were invisible? and the flames the first boss throws too? It s very strange that ... on my PC, no object is invisible in my poor game ... Could it be a failure on the image files?

About porting SFML apps from 32 to 64 bit, I found out that what I needed to change was the SFML DLLs, the C# code is the same, actually I compiled the 32 bit version with x86 DLLs, and the 64 bit version with x64 DLLs,

32 bit download

https://www.dropbox.com/s/9ikj1kbm53oqpp3/Sonic%20the%20Hedgehog%20by%20Pablito.rar

64 bit download

https://www.dropbox.com/s/xm54luwk8wehynb/Sonic%2064%20bit%20by%20Pablito.rar

Source Code (fixed) (for both 32 and 64 bit)

https://www.dropbox.com/s/tzts0sy3s6hswj4/SOURCE%20CODE.rar

Those who want to compile the code, remember to add the SFML.NET DLLs to the References node, on the Solution Explorer, but the x86 if the system is 32 bit, or the x64 if it is 64 bit ... there they are in each game version, in the exe's folder

What I would like is that someone goes along up to the Zone 2 Act 2, beats it (Eggman at the end), and then tells me why, while trying to load Zone 3 Act 1, my hedgehog runs with a OutOfMemoryException ... obviously it is not a lack of memory, because I have 2 GB, ... and the blue screen, I put them to inform about the used memory (on each level, whose sizes are different), without success as seen ... as seen at finishing 2-2

The code about loading levels and that stuff can be found in the LEVEL subfolder from the source code
(I also tried using the GC, but no effect ... it should be a lost reference that remains anywhere, or a failure in the Image class (the Zone image files are quit big, and JPG), or a failure on the image files, ... or I don t know what)

Thank you all


Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #10 on: September 24, 2013, 10:54:39 pm »
I don't recall seeing any zone/act names or any method of saving my progress, so assuming I'm not missing something, how long do you think it'd take me to get to Eggman?

Edit: This version locks up for me.  After the used memory screen I get a white screen with blue text that says it failed to load an image (the filename flies off the screen so I have no idea which one) and gives another used memory number.  It never seems to recover from that.
« Last Edit: September 24, 2013, 11:08:28 pm by Ixrec »

Sub

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #11 on: September 24, 2013, 11:13:48 pm »
It's an improvement over the older build, but I'm still having issues.

  • On the initial screen, I get horizontal black bars which move either up or down.  I was able to get past this screen no problem, though
  • Alt tabbing was fixed
  • Character selection was also now good
  • I still got the blue used memory screen, at which point it failed to load an image file, I can't tell which image file because the name gets cut off.  It's at this point that it crashes

Sorry man.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #12 on: September 25, 2013, 12:36:05 am »
It's OK, come on everybody!  :)
I don't know why, a few files had gone, now I restored them, removed the "memory used" messages, and reuploaded the 3 rar files, that are

Sonic 32 bit Version
https://www.dropbox.com/s/9ikj1kbm53oqpp3/Sonic%20the%20Hedgehog%20by%20Pablito.rar

Sonic 64 bit Version
https://www.dropbox.com/s/xm54luwk8wehynb/Sonic%2064%20bit%20by%20Pablito.rar

Sonic Source Code both 32 and 64 bit
https://www.dropbox.com/s/tzts0sy3s6hswj4/SOURCE%20CODE.rar

It would take you about 5 or 6 minutes to reach Eggman on the Zone 2 Act 2, ... that is where it launches an OutOfMemoryException, on trying to load Zone 3 Act 1 ... The problem should not be that there's no more memory in my system, I have 2 GB, then I think now it's all fixed excepting that ...  :(

(at act 1 ends, you have a mini boss, at act 2 ends, comes Dr Eggman (Robotnik))
(you hit enemies with Sonic become a spinball, jumping or rolling, if not, or if touch fire or a hog, you are hit)
(to pass over the ramps, do the spindash: hold down Down key, then press Space once and again, to gain impulse, then release both and press forward key(Right or Left, depending))

The issue of the bars in the initial screen, the invisible stuff, etc, I supose they don't have to do with my C# code ... perhaps it's the 64 bit system

Thanks for your patience  :D

PS please don't select Tails the Foxhog, there's another bug by now, she can't run on the ramps nor fly ... I'll fix that  8)

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #13 on: September 25, 2013, 01:23:31 am »
Man, so many things to check and report on...

The blue used memory screens are still there.  The loading level screen now has a used memory number on it.
The springs and boss flame are now visible.
Most pieces of scenery have some weird purple stuff around them.
The main menu is sometimes pure white, and sometimes has several flickering black bars over it.  I think this was the case in some but not all of the previous builds, not sure anymore.
Alt+tab does absolutely nothing (this has been the case for me in all builds, it's never crashed it for me).  I have to ctrl+alt+delete in order to escape the game.  Can you please make a windowed version so it's less annoying to test?
Escape seems to sort of work but the main menu remains glitchy and sometimes it doesn't respond and I have to kill the program.
Why is there a console window anyway?  You don't seem to be doing anything with it.

I'll edit this once I get through more levels.  Gonna try to get to Eggman like you asked.

I tried to take screenshots of some of these things but all I get are blank images.

Gotta be honest, this whole thing is giving me an extremely bad impression of C#/.NET/SFML.net.  I've never had to deal with anything resembling a single one of these problems for my C++ SFML program. 
« Last Edit: September 25, 2013, 01:25:02 am by Ixrec »

Sub

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Re: My Sonic the Hedgehog game (goes fine, but need help)
« Reply #14 on: September 25, 2013, 01:37:09 am »
Another improvement, I was actually able to play it this time  :)

I'd echo everything Ixrec has said, but in addition to that, there was a spot on level 2 where I became stuck.  There was a completely vertical hill that I fell down, so I was caught between a hill that was too tall to get back up on, and one of the loops that you have to run around.  I couldn't gain enough speed to get through the loop.  I would have taken a screenshot, but printscreen doesn't seem to work with the game?

 

anything