* * *

Author Topic: Game Contest 2018  (Read 23900 times)

User137

  • Hero Member
  • *****
  • Posts: 1743
    • Nxpascal home
Re: Game Contest 2018
« Reply #135 on: May 08, 2018, 02:33:56 pm »
For me too, or use Paint instead of Invalidate in OnTimer-Event.
What i do in nxPascal demos is initialize graphics in form's onPaint event directly, and then disable the onPaint from triggering again. Then you don't need code in onCreate or a separate timer.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 773
    • Burdjia
Re: Game Contest 2018
« Reply #136 on: May 09, 2018, 01:52:38 pm »
I mean, AFAIK FPC is case insensitive when looking for units so it should find "utf8utils" despite the letter casing and the operating system.  May be you configured the project in a way it is case sensitive?  I'm not sure it is possible though.

Linux is case sensitive, your suggestion that FPC should find the lower case sounds a solution. But it is not a good solution. I personally prefer CamelCase instead of lower case. For example:
sysexecutable.pas vs SysExecutable.pas
My filenames are always in lowercase, my UNIT names are CamelCase though.  And they work both Linux and Windows.  That's why I asked.  :o
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Lulu

  • Jr. Member
  • **
  • Posts: 82
Re: Game Contest 2018
« Reply #137 on: May 11, 2018, 03:37:26 pm »
About FireAndWire game,I removed the 'UTF8Util.pas' dependency because this unit is no longer used by the framework. :-[

Thanks Handoko for corrections to the code. I fixed them. I apologize for these case sensitives redundant errors ... Maybe I should install a version of linux on my computer ...

As the game is quite long and repetitive, I added an automatic backup by player and level, and the choice between 5 languages (I use google traduction for italian, spanish and english...). Now the game has 32 levels.

Latest version of the code:  www.lulutech.fr/Logitheque/FireWire/FireWireGameSrc.7z
Compiled version for Windows:  www.lulutech.fr/Logitheque/FireWire/FireAndWire.zip

The new title screen for the game:

« Last Edit: May 12, 2018, 10:06:18 am by Lulu »
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
very bad english... sorry :)

Handoko

  • Hero Member
  • *****
  • Posts: 2254
  • My goal: build my own game engine using Lazarus
Re: Game Contest 2018
« Reply #138 on: May 12, 2018, 10:43:05 am »
Did you use any language feature that require FPC version above 3.0.4? It fails to compile on my Lazarus 1.8.0 64-bit Gtk2 FPC 3.0.4 Linux.

Lulu

  • Jr. Member
  • **
  • Posts: 82
Re: Game Contest 2018
« Reply #139 on: May 12, 2018, 03:42:06 pm »
@Handoko, these lines are used to initialize the values of a constant record, here, the value for the default font.
I take a look on TBGRAPixel definition in TBGRABitmap library and its fields are defined :
Code: Pascal  [Select]
  1.     {$IFDEF BGRABITMAP_RGBAPIXEL}
  2.     red, green, blue, alpha: byte;
  3.     {$ELSE}
  4.     blue, green, red, alpha: byte;
  5.     {$ENDIF}
  6.  

So, with the line below, it will normaly work for you
Code: Pascal  [Select]
  1. const
  2. {$IFDEF BGRABITMAP_RGBAPIXEL}
  3. DefaultFont: TGuiFont=( FontName:''; FontHeight:12; Style:[];FontColor:(red:255;green:255;blue:255;alpha:255);
  4.                         OutLineColor:(red:0;green:0;blue:0;alpha:0); OutLineWidth: 1.0;
  5.                         ShadowColor:(red:0;green:0;blue:0;alpha:0); ShadowOffsetX:0;
  6.                         ShadowOffsetY:0; ShadowRadius:0);
  7. {$ELSE}
  8. DefaultFont: TGuiFont=( FontName:''; FontHeight:12; Style:[];FontColor:(blue:255;green:255;red:255;alpha:255);
  9.                         OutLineColor:(blue:0;green:0;red:0;alpha:0); OutLineWidth: 1.0;
  10.                         ShadowColor:(blue:0;green:0;red:0;alpha:0); ShadowOffsetX:0;
  11.                         ShadowOffsetY:0; ShadowRadius:0);
  12. {$ENDIF}
  13.  
Fixed in the source code, Thanks Handoko :)
« Last Edit: May 12, 2018, 03:49:36 pm by Lulu »
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
very bad english... sorry :)

Handoko

  • Hero Member
  • *****
  • Posts: 2254
  • My goal: build my own game engine using Lazarus
Re: Game Contest 2018
« Reply #140 on: May 17, 2018, 06:04:00 am »
Code: Pascal  [Select]
  1. const
  2. {$IFDEF BGRABITMAP_RGBAPIXEL}
  3. DefaultFont: TGuiFont=( FontName:''; FontHeight:12; Style:[];FontColor:(red:255;green:255;blue:255;alpha:255);
  4.                         OutLineColor:(red:0;green:0;blue:0;alpha:0); OutLineWidth: 1.0;
  5.                         ShadowColor:(red:0;green:0;blue:0;alpha:0); ShadowOffsetX:0;
  6.                         ShadowOffsetY:0; ShadowRadius:0);
  7. {$ELSE}
  8. DefaultFont: TGuiFont=( FontName:''; FontHeight:12; Style:[];FontColor:(blue:255;green:255;red:255;alpha:255);
  9.                         OutLineColor:(blue:0;green:0;red:0;alpha:0); OutLineWidth: 1.0;
  10.                         ShadowColor:(blue:0;green:0;red:0;alpha:0); ShadowOffsetX:0;
  11.                         ShadowOffsetY:0; ShadowRadius:0);
  12. {$ENDIF}
  13.  

I managed to fix the compile-time error but only I use @IFNDEF.

But now I got a runtime-error because the program try to create the folder /etc/Lulutech. I believe it is a permission issue, 'common' users are not allowed to modify things inside /etc.

Lulu

  • Jr. Member
  • **
  • Posts: 82
Re: Game Contest 2018
« Reply #141 on: May 17, 2018, 05:21:08 pm »
Hello Handoko :) Thanks for your interest and your patience !
For me, (on windows) the IFNDEF directive don't work...
So, I replaced the const declaration by a function the return the default font. I think it will remove all problems
Code: Pascal  [Select]
  1. function DefaultFont: TGuiFont;
  2. ...
  3. function DefaultFont: TGuiFont;
  4. begin
  5.  Result.FontName:='';
  6.  Result.FontHeight:=12;
  7.  Result.Style:=[];
  8.  Result.FontColor:=BGRAWhite;
  9.  Result.OutLineColor:=BGRABlack;
  10.  Result.OutLineWidth:= 1.0;
  11.  Result.ShadowColor:=BGRABlack;
  12.  Result.ShadowOffsetX:=0;
  13.  Result.ShadowOffsetY:=0;
  14.  Result.ShadowRadius:=0;
  15. end;
  16.  

For the problems file access, I use GetAppConfigDirUTF8 to retrieve a folder where to save a config file for the game (player list, last player...). I have just re-read the documentation of this function and I have not taken into account the note 'On Linux, normal users are not allowed to write to the /etc directory. Only users with administration rights can do this.'
So, in the game source, in the unit 'AppIniFile.pas', at line 81 I changed the previous code
Code: Pascal  [Select]
  1. Result := IncludeTrailingPathDelimiter( GetAppConfigDirUTF8(TRUE, TRUE) );
  by
Code: Pascal  [Select]
  1. {$IFDEF WINDOWS}
  2.   Result := IncludeTrailingPathDelimiter( GetAppConfigDirUTF8(TRUE, TRUE) );
  3. {$ELSE}
  4.   Result := IncludeTrailingPathDelimiter( GetAppConfigDirUTF8(FALSE, TRUE) );
  5. {$ENDIF}
  6.  
The first parameter of the GetAppConfigDirUTF8 function is set to FALSE in the Linux version -> this return the local user folder and not the global. I hope this will remove the run time error.
source code updated: www.lulutech.fr/Logitheque/FireWire/FireWireGameSrc.7z
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
very bad english... sorry :)

Handoko

  • Hero Member
  • *****
  • Posts: 2254
  • My goal: build my own game engine using Lazarus
Re: Game Contest 2018
« Reply #142 on: May 17, 2018, 06:17:45 pm »
Thank you for the update.

But now the program exits immediately after starting. After I enable the debug info, I got a runtime error 232. And this is what the documentation says:

Quote
232 Threads not supported
Thread management relies on a separate driver on some operating systems (notably, Unixes). The unit with this driver needs to be specified on the uses clause of the program, preferably as the first unit (cthreads on unix).

I don't know much about it, maybe some seniors can help.

Lulu

  • Jr. Member
  • **
  • Posts: 82
Re: Game Contest 2018
« Reply #143 on: May 17, 2018, 08:08:55 pm »
This time, I think the problems come that the project is in 'final' build mode, and in this mode, I forget to declare the -dDYNLINK and -dUseCThreads compile options... I only declare them in default mode... Sorry  :-[
I hope this time it will run.
Code updated in the previous link.
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
very bad english... sorry :)

Handoko

  • Hero Member
  • *****
  • Posts: 2254
  • My goal: build my own game engine using Lazarus
Re: Game Contest 2018
« Reply #144 on: May 18, 2018, 02:34:21 pm »
Hooray, it finally compiled and run without error.

But it still has an issue. I can't read the instruction. Tested on Lazarus 1.8.0 64-bit Gtk2 Ubuntu Mate 17.10 using GeForce GT 430 24-inch monitor.

Lulu

  • Jr. Member
  • **
  • Posts: 82
Re: Game Contest 2018
« Reply #145 on: May 18, 2018, 09:28:26 pm »
Hooray, and... Ouch !... what a chain of problems ! it shows my level of programming ...
May be you have time again to do another try...

In the Main unit, -> object inspector, ->Form_Main, could you please change the WindowState property to wsNormal, and set the Width form to 1024 and height to 768 ?
« Last Edit: May 18, 2018, 09:41:26 pm by Lulu »
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
very bad english... sorry :)

lainz

  • Hero Member
  • *****
  • Posts: 2620
  • I'm coding :)
    • Lainz
Re: Game Contest 2018
« Reply #146 on: May 18, 2018, 11:47:55 pm »
1024x768? My childhood memories are getting back to my mind.  :D

Handoko

  • Hero Member
  • *****
  • Posts: 2254
  • My goal: build my own game engine using Lazarus
Re: Game Contest 2018
« Reply #147 on: May 19, 2018, 07:50:14 am »
Here it is, WindowState :=  wsNormal and size := 1024 x 768.

circular

  • Hero Member
  • *****
  • Posts: 2677
    • Personal webpage
Re: Game Contest 2018
« Reply #148 on: May 19, 2018, 10:35:26 am »
Maybe there is problem with font size.
Conscience is the debugger of the mind

Lulu

  • Jr. Member
  • **
  • Posts: 82
Re: Game Contest 2018
« Reply #149 on: May 19, 2018, 10:54:27 pm »
yes Circular, it is a font problem. I don't understand why the text is showned well on Windows and not on Linux.
In the game, the instructions are showned using the class TGuiTextArea. In TGuiTextArea.Create(...) an TBGRATextEffectFontRenderer associated with TBGRABitmap.TextRect() draw the text with the appropriate font on a TBGRABitmap, then convert it to opengl texture.
After few search, I found perhaps the issue:

In unit 'u_SpriteDefinition', line 543 there was:
Code: Pascal  [Select]
  1.  // child 1: TGuiTextArea to show the instructions in the appropriate language
  2.  FTextArea := TGuiTextArea.Create( StrRes[10,FCurrentCountry], 25, 25, Width-50, Height-50,
  3.                                    GuiFont('', 17, [], BGRA(200,200,200), BGRA(0,0,0), 3,
  4.                                    BGRA(0,0,0), 1, 1, 7), taCenter, tlCenter);
  5.  

In the Font definition, there is no name specified. I added 'Arial':
Code: Pascal  [Select]
  1.  // child 1: TGuiTextArea to show the instructions in the appropriate language
  2.  FTextArea := TGuiTextArea.Create( StrRes[10,FCurrentCountry], 25, 25, Width-50, Height-50,
  3.                                    GuiFont('Arial', 17, [], BGRA(200,200,200), BGRA(0,0,0), 3,
  4.                                    BGRA(0,0,0), 1, 1, 7), taCenter, tlCenter);
  5.  

Same with the country's panel, unit 'u_screen_title',  line 151.

I updated the code in the previous link.
I hope... :D
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
very bad english... sorry :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus