Recent

Author Topic: [SOLVED] Images not found when starting SDL2 game in an other computer  (Read 21592 times)

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Images not found when starting SDL2 game in an other computer
« Reply #30 on: September 11, 2016, 07:56:36 pm »
...
Thanks again for replies! I appreciate so much them, i will upload my game as soon as possible. ;D
In case you have uploaded (again, as i was unable to download it earlier) then unfortunately you still got a problem as it won't load on windows XP. Sorry for that.
(the version i tested was 265.841 bytes in size and dated 5-9-2106 19:07:14)

1) i am able to see this inside your exe: "C:\WINDOWS\fonts\Candara.ttf",  and i do not have that font.
Do you have proper fallback code in place for that ?

2) i am not sure, but distributing msvcp110.dll and msvcr110.dll might get you in troubles with M$. I am aware they are needed, but usually when the case the person that published the game, points to the download links for those file (it is part of a visual c distributable from microsoft which is (usually) freely available).

As a generic hint (as i also saw that inside your filepath routine), instead of just calling halt() to exit your routine in case something did go wrong, please please please write a message telling what exactly went wrong (you know it as you wrote the code). You can write it to anywhere you want to, to a shell, to a file or debug. At the least provide an error number or something, so that you are able to find it back inside your code in case people report back to you.

Usually when you see example code, almost nobody is showing/telling you how ugly their code becomes when adding proper error handling support. That is also the reason why you do not see much of such code  ;-)

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Images not found when starting SDL2 game in an other computer
« Reply #31 on: September 11, 2016, 08:18:58 pm »
...
Thanks again for replies! I appreciate so much them, i will upload my game as soon as possible. ;D
In case you have uploaded (again, as i was unable to download it earlier) then unfortunately you still got a problem as it won't load on windows XP. Sorry for that.
(the version i tested was 265.841 bytes in size and dated 5-9-2106 19:07:14)

1) i am able to see this inside your exe: "C:\WINDOWS\fonts\Candara.ttf",  and i do not have that font.
Do you have proper fallback code in place for that ?

2) i am not sure, but distributing msvcp110.dll and msvcr110.dll might get you in troubles with M$. I am aware they are needed, but usually when the case the person that published the game, points to the download links for those file (it is part of a visual c distributable from microsoft which is (usually) freely available).

As a generic hint (as i also saw that inside your filepath routine), instead of just calling halt() to exit your routine in case something did go wrong, please please please write a message telling what exactly went wrong (you know it as you wrote the code). You can write it to anywhere you want to, to a shell, to a file or debug. At the least provide an error number or something, so that you are able to find it back inside your code in case people report back to you.

Usually when you see example code, almost nobody is showing/telling you how ugly their code becomes when adding proper error handling support. That is also the reason why you do not see much of such code  ;-)
ok thanks for the hint, now ( 8:16 p.m ) so this evening i will try this and upload this game..
I posted this tread because not working on windows 10, but for me, ALL works fine.
I inserted msvcp110.dll and msvcr110.dll because i don't know if someone open the game and there are file missing.
Ok, as soon as possible!
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: Images not found when starting SDL2 game in an other computer
« Reply #32 on: September 11, 2016, 08:31:29 pm »
@Molly

You're really perceptive.

Candara font belong to Microsoft.
https://en.wikipedia.org/wiki/Candara

Usually, most fonts are free to use. But it doesn't mean we're free to distribute them.

I'm a freelance graphics designer. License is a sensitive thing to me. Here I have a list of public domain fonts (can be distribute freely):

Aquifer
http://www.1001fonts.com/aquifer-font.html

BlackChancery
http://www.1001fonts.com/blackchancery-font.html

Bradley Gratis
http://www.1001fonts.com/bradley-gratis-font.html

Goudy Bookletter 1911
http://crudfactory.com/font/show/gb1911

Heavy Equipment
http://www.1001fonts.com/heavy-equipment-font.html

Juvelo
http://crudfactory.com/font/show/juvelo

Pretzel
http://www.1001fonts.com/pretzel-font.html

Prociono
http://crudfactory.com/font/show/prociono

Promocyja
http://www.1001fonts.com/promocyja-font.html

TempoFont
http://www.1001fonts.com/tempofont-font.html

Topeka
http://www.1001fonts.com/topeka-font.html

Quote
2) i am not sure, but distributing msvcp110.dll and msvcr110.dll might get you in troubles with M$. I am aware they are needed, but usually when the case the person that published the game, points to the download links for those file (it is part of a visual c distributable from microsoft which is (usually) freely available).

Why msvc*.dll are needed? Is it because he uses SDL?
I was thinking to learn SDL. But if SDL needs msvc*.dll, now I have reason not to learn it.

Quote
As a generic hint (as i also saw that inside your filepath routine), instead of just calling halt() to exit your routine in case something did go wrong, please please please write a message telling what exactly went wrong (you know it as you wrote the code). You can write it to anywhere you want to, to a shell, to a file or debug. At the least provide an error number or something, so that you are able to find it back inside your code in case people report back to you.

Simply showing a message is okay. But it should able to log the detail information of the error to a file. Because if the program causes error, you can ask the user to send or email you the log file for you to help you inspect the problem.

Quote
Usually when you see example code, almost nobody is showing/telling you how ugly their code becomes when adding proper error handling support. That is also the reason why you do not see much of such code  ;-)

Error handling is an advanced topic. Novice programmers usually don't like this one, because it is more exciting to see the program running, making sounds and animations rather than thinking what error could possibly happens.  :D
« Last Edit: September 11, 2016, 08:34:27 pm by Handoko »

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Images not found when starting SDL2 game in an other computer
« Reply #33 on: September 11, 2016, 08:45:14 pm »
okay please download my game and see if that works..
download link is here .. on the personal post text.. here below
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: Images not found when starting SDL2 game in an other computer
« Reply #34 on: September 11, 2016, 09:08:13 pm »
 :D Congratulation!  :D

It runs, even on my Linux PC using Wine.

 :'( Unfortunately, there are some noticeable bugs.

Issue 1
The screen didn't scale automatically following my settings, you can see the screen was cut on the right side.

Issue 2
After some screen size adjustment testings, I can saw and started the game. But it run to fast. In just 2 seconds the player died, don't know what has happened. Perhaps I have a too fast computer, it is Core 2 Quad, not the best but above average.

Now is late midnight here. I will try to get a Windows computer tomorrow to test your game.
« Last Edit: September 11, 2016, 09:11:09 pm by Handoko »

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Images not found when starting SDL2 game in an other computer
« Reply #35 on: September 11, 2016, 09:12:38 pm »
:D Congratulation!  :D

It runs, even on my Linux PC using Wine.

 :'( Unfortunately, there are some noticeable bugs.

Issue 1
The screen didn't scale automatically following my settings, you can see the screen was cut on the right side.

Issue 2
After some screen size adjustment testings, I can saw and started the game. But it run to fast. In just 2 seconds the player died, don't know what has happened. Perhaps I have a too fast computer, it is Core 2 Quad, not the best but above average.

Now is late midnight here. I will try to get a Windows computer to test your game tomorrow.
okay please download my game and see if that works..
download link is here .. on the personal post text.. here below
Ehm, ok i need help for this.. For velocity.. Because on my computer it doesn't go fast but so slow..
How can i fix that? Same velocity for all? My pc is slow but other games run perfectly ( with some lags but no slowly) please help
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Images not found when starting SDL2 game in an other computer
« Reply #36 on: September 11, 2016, 09:16:31 pm »
And another thing.. I have a portable pc with 1366x766 of resolution so i should fix for square screen.
And i should ask if the music is listened.. After opened the game there should be a song played.. If not then check "error" folder and the error written in the error.txt.. (Music not played) .
Then, really i worked so hard for options section! Check source code and see if it goes good!! Please i appreciate all
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: Images not found when starting SDL2 game in an other computer
« Reply #37 on: September 11, 2016, 09:28:44 pm »
As far as I know there are several techniques can be used.

First, when the program start, it benchmarks your computer performance automatically, then it uses the performance factor to delay the looping.

The second one is to use a fix frames per second (fps) rates. If you set it 60 fps, then the computer will try to do 60 loopings in a second ignoring the computer speed. But the downside is, it don't work accurately if the computer is too slow.

The third, which I think is the best is to use a delta time of each frame drawing. And includes it into the movement calculation.
http://gameprogrammingpatterns.com/game-loop.html

I'm not sure you will understand, because for beginners you should try something much more simpler. The tutorial above use C (perhaps C++), but the explanation is easy to understand. The secret is in the game looping as I ever mentioned.

Quote
I have a portable pc with 1366x766 of resolution so i should fix for square screen.

How to make games look good on different screens is another long topic. Several possibilities are available: stretching, cropping, filling, forcing resolution. Each of them has their own advantages/disadvantages, it is hard to say which is the best.

Quote
And i should ask if the music is listened.

No audio here. You should know, not all Windows programs can run correctly on Linux/Wine.

It's 2.30 AM here, I'm going to sleep now.
« Last Edit: September 11, 2016, 09:38:47 pm by Handoko »

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Images not found when starting SDL2 game in an other computer
« Reply #38 on: September 11, 2016, 10:02:20 pm »
As far as I know there are several techniques can be used.

First, when the program start, it benchmarks your computer performance automatically, then it uses the performance factor to delay the looping.

The second one is to use a fix frames per second (fps) rates. If you set it 60 fps, then the computer will try to do 60 loopings in a second ignoring the computer speed. But the downside is, it don't work accurately if the computer is too slow.

The third, which I think is the best is to use a delta time of each frame drawing. And includes it into the movement calculation.
http://gameprogrammingpatterns.com/game-loop.html

I'm not sure you will understand, because for beginners you should try something much more simpler. The tutorial above use C (perhaps C++), but the explanation is easy to understand. The secret is in the game looping as I ever mentioned.

Quote
I have a portable pc with 1366x766 of resolution so i should fix for square screen.

How to make games look good on different screens is another long topic. Several possibilities are available: stretching, cropping, filling, forcing resolution. Each of them has their own advantages/disadvantages, it is hard to say which is the best.

Quote
And i should ask if the music is listened.

No audio here. You should know, not all Windows programs can run correctly on Linux/Wine.

It's 2.30 AM here, I'm going to sleep now.
Game looping is complicated as i see in C programming.. Hope i will find how in Pascal
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Images not found when starting SDL2 game in an other computer
« Reply #39 on: September 11, 2016, 10:09:15 pm »
Why msvc*.dll are needed? Is it because he uses SDL?
I was thinking to learn SDL. But if SDL needs msvc*.dll, now I have reason not to learn it.
Well, SDL libraries were probably compiled with MS visual c compiler. At least msvcrt.dll would be required in that case.

SDL also relies on kernel.dll so... would that be reason to stop using SDL ? ;-)

fwiw: when SDL libs are compiled using mingw it also relies on msvcrt as it is the whole lidea behind mingw. Compiling under cywin adds the need for the end-user to have a working cygwin environment.

It is the priice to pay for making stuff cross platform compatible, even though every windows i know has msvcrt runtime libray installed.

DLL dependency walker did not reveal to me these libraries are needed.

Quote
Error handling is an advanced topic. Novice programmers usually don't like this one, because it is more exciting to see the program running, making sounds and animations rather than thinking what error could possibly happens.
Admittingly, initially i do not add error checking myself as well. It is when running into issues that i start adding them as well as testing on other systems. First i like to see if theory works before continuing.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Images not found when starting SDL2 game in an other computer
« Reply #40 on: September 11, 2016, 10:17:28 pm »
And i should ask if the music is listened.. After opened the game there should be a song played.. If not then check "error" folder and the error written in the error.txt.. (Music not played) .
Then, really i worked so hard for options section! Check source code and see if it goes good!! Please i appreciate all
Sound is also not played here.

But, i probably know the reason for this ;-)

edit:
Here is some code for you to try:
Code: Pascal  [Select][+][-]
  1. program playmp3;
  2.  
  3. {$UNITPATH ..\SDL2Units}  // this is for my personal setup, remove for yours.
  4. {$MODE OBJFPC}{$H+}
  5.  
  6. uses
  7.   SDL2, SDL2_Mixer, SysUtils;
  8.  
  9. var
  10.   MY_COOL_MP3 : PChar;
  11.  
  12.  
  13. (*
  14.   Seems that SDL_QuitRequested is not part of SDL2 Pascal headers, so we
  15.   implement it here for convenience.
  16.   This implementation slightly differs from the original macro so it complies
  17.   more with Pascal usage, returning a boolean value
  18. *)
  19.  
  20. function SDL_QuitRequested: Boolean;
  21. begin
  22.   SDL_PumpEvents;
  23.   Result := (SDL_PeepEvents(nil, 0, SDL_PEEKEVENT, SDL_QUITEV, SDL_QUITEV) > 0)
  24. end;
  25.  
  26.  
  27. function Main: Integer;
  28. var
  29.   answer : integer = 0;
  30.   flags  : integer = MIX_INIT_MP3;
  31.   music  : PMix_Music;
  32. begin
  33.   if (SDL_Init(SDL_INIT_AUDIO) < 0) then
  34.   begin
  35.     WriteLn('Failed to init SDL');
  36.     exit(1);
  37.   end;
  38.  
  39.   answer := Mix_Init(flags);
  40.   if (flags <> answer) then
  41.   begin
  42.     WriteLn('Could not initialize mixer (result: ', answer, ').');
  43.     WriteLn('Mix_Init: ', Mix_GetError());
  44.     exit(1);
  45.   end;
  46.  
  47.   Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 640);
  48.   music := Mix_LoadMUS(MY_COOL_MP3);
  49.   Mix_PlayMusic(music, 1);
  50.  
  51.   while not(SDL_QuitRequested) do
  52.   begin
  53.     SDL_Delay(250);
  54.   end;
  55.  
  56.   Mix_FreeMusic(music);
  57.   SDL_Quit();
  58.   exit(0)
  59. end;
  60.  
  61.  
  62. begin
  63.   if (ParamCount <> 1) then
  64.   begin
  65.     WriteLn('Usage: PlayMp3 filename');
  66.     ExitCode := 3;
  67.     exit;
  68.   end;
  69.  
  70.   If FileExists(ParamStr(1)) then
  71.   begin
  72.     MY_COOL_MP3 := PChar(ParamStr(1));
  73.     ExitCode := Main;
  74.   end
  75.   else
  76.   begin
  77.     WriteLn('Unable to locate MP3 with name ', ParamStr(1));
  78.     ExitCode := 4;
  79.   end;
  80. end.
  81.  

It originates from this github source, converted to pascal by me.

When using your distribution files it shows:
Code: [Select]
Could not initialize mixer (result: 0)
Mix_Init: Failed loading smpeg2.dll: The specified module could not be found.

And, indeed that libary is missing ;-)
« Last Edit: September 12, 2016, 12:31:49 am by molly »

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Images not found when starting SDL2 game in an other computer
« Reply #41 on: September 11, 2016, 11:40:58 pm »
The game runs too fast but its fun to play that fast :)
There is no sound for me under Windows 10.

Here is a video, when I was recording the video with Open Broadcaster Software (OBS) the speed is half the speed when I'm not recording. The window size is 1920x1080.

YouTube: https://youtu.be/EtdqRpaKwRU

When trying to render with Windows 10 Recorder (Win Key + G) says that there is nothing to record, maybe I can not record opengl games with that tool.

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Images not found when starting SDL2 game in an other computer
« Reply #42 on: September 11, 2016, 11:44:40 pm »
The game runs too fast but its fun to play that fast :)
There is no sound for me under Windows 10.

Here is a video, when I was recording the video with Open Broadcaster Software (OBS) the speed is half the speed when I'm not recording. The window size is 1920x1080.

YouTube: https://youtu.be/EtdqRpaKwRU

When trying to render with Windows 10 Recorder (Win Key + G) says that there is nothing to record, maybe I can not record opengl games with that tool.
I saw the video! But that speed in the video is the speed i normally have. I notice you don't know that you can use other keys.. The arrows : the dino can move left and right too. Jumping and moving together.
For resoultion i must find a way but i don't know now.
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Images not found when starting SDL2 game in an other computer
« Reply #43 on: September 11, 2016, 11:49:38 pm »
I'm used to move with w, s, a, d not the arrow keys (except on emulators) :)

PD: You can download my game with lazarus fpc here: https://sourceforge.net/projects/leveloid/

Hey my game moves with the arrow keys too  ::)

And the source code is here: https://github.com/bgrabitmap/bgragames/tree/master/test/leveloid/leveloid

You need to install BGRABitmap, BGLControls, and BGRAGames packages to compile it. There are a lot of dll needed for audio too.
« Last Edit: September 12, 2016, 12:01:55 am by lainz »

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Images not found when starting SDL2 game in an other computer
« Reply #44 on: September 12, 2016, 12:28:08 am »
I saw the video! But that speed in the video is the speed i normally have. I notice you don't know that you can use other keys.. The arrows : the dino can move left and right too. Jumping and moving together.
For resoultion i must find a way but i don't know now.
fwiw: the speed was good for me. That seems a bit odd that others report the game is too fast but perhaps it has to do with my screen szie :-)

The size is indeed problematic. I played on 1920x1080 and the pixels drawing is situated at the left (which is ok i guess), but the ufo and plants are coming in from the far right side (into an area where there is not further drawing, slowly entering into the rest of the game graphics).

There are several options you can try to solve it but they have different approaches
1) bound your game to a certain screen resolution. not very nice, but some games do this.
2) up or downscale your game graphics screen on every frame
3) recalculate the coordinate system you use and adjust (up or downscale) these coordinates depending on user's screen resolution.

 

TinyPortal © 2005-2018