Lazarus

Free Pascal => Beginners => Topic started by: justnewbie on April 28, 2018, 03:05:39 pm

Title: Moving shape with keys
Post by: justnewbie on April 28, 2018, 03:05:39 pm
Hi,
This code works:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.    case Key of
  4.     VK_LEFT:
  5.       Shape1.Left := Shape1.Left - 15;
  6.     VK_RIGHT:
  7.       Shape1.Left := Shape1.Left + 15;
  8.   end;
  9. end;

This code doesn't work:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.    case Key of
  4.     VK_LSHIFT:
  5.       Shape1.Left := Shape1.Left - 15;
  6.     VK_RSHIFT:
  7.       Shape1.Left := Shape1.Left + 15;
  8.   end;
  9. end;

What is the problem in the second case (using shift keys)?
Title: Re: Moving shape with keys
Post by: User137 on April 28, 2018, 04:12:51 pm
OnKeyDown can't distinct left and right shift presses, they both return VK_SHIFT (int 16). You can find that with:
Code: Pascal  [Select][+][-]
  1. caption:=inttostr(key);

But i don't know of easy way to do that. If it's important, you can give more details on what it's used for and if it's ok to have it only work on Windows platform.
Title: Re: Moving shape with keys
Post by: ASerge on April 28, 2018, 04:58:52 pm
Code: Pascal  [Select][+][-]
  1. uses LclType, LclIntf;
  2.  
  3. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  4. begin
  5.   if Key = VK_SHIFT then
  6.     if GetKeyState(VK_LSHIFT) < 0 then
  7.       Shape1.Left := Shape1.Left - 15
  8.     else
  9.       Shape1.Left := Shape1.Left + 15;
  10. end;
Title: Re: Moving shape with keys
Post by: Handoko on April 28, 2018, 05:18:13 pm
@justnewbie

Maybe you can find what you want here:
http://forum.lazarus.freepascal.org/index.php?topic=36590.0 (http://forum.lazarus.freepascal.org/index.php?topic=36590.0)

The easiest way is to use a game engine that support reading the shift keys. For example Allegro, I used it to create Furious Paladin which the moving is controlled by using left/right ctrl:
http://forum.lazarus.freepascal.org/index.php/topic,35313.msg254588.html#msg254588 (http://forum.lazarus.freepascal.org/index.php/topic,35313.msg254588.html#msg254588)

Code: Pascal  [Select][+][-]
  1.   // Moving or attacking
  2.   isMoveLeft  := al_key_down(KeyState, ALLEGRO_KEY_LCTRL);
  3.   isMoveRight := al_key_down(KeyState, ALLEGRO_KEY_RCTRL);
  4.  

The whole source code can be found here:
https://sourceforge.net/p/allegro-pas/code/HEAD/tree/TRUNK/demos/furiouspaladin/furiouspaladin.pas (https://sourceforge.net/p/allegro-pas/code/HEAD/tree/TRUNK/demos/furiouspaladin/furiouspaladin.pas)
Title: Re: Moving shape with keys
Post by: justnewbie on April 28, 2018, 07:59:09 pm
Guys, thank you for the answers!
It is a totally basic tennis/pong game.
It is not so important for me, but it is a bit strange that why is the difference between the left/right keys and shift keys.
I can live with left/right keys, not problem.

@ASerge: somehow this code doesn't work well.
1./ although I press the key continuously, only 1 step occurs
2./ the moving direction is from right to left only
Title: Re: Moving shape with keys
Post by: jamie on April 28, 2018, 10:08:39 pm
maybe you have more than one key down ?

Try this

 If VK_SHIFT in [KEY] Then......

Edit:

  I made a boo boo  :)
if should be

 If ssShift in Shift Then......

Title: Re: Moving shape with keys
Post by: ASerge on April 29, 2018, 09:52:22 am
@ASerge: somehow this code doesn't work well.
1./ although I press the key continuously, only 1 step occurs
2./ the moving direction is from right to left only
I tested only on Windows. Possible on other platforms:
1. Repeated press do not reach the OnKeyDown handler.
2. Not Left Shift key not equal Right Shift.
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 10:39:01 am
@jamie: unfortunately no success

@ASerge: yes, it seems your code is system-specific, it is a Linux system. OnKeyDown worked well using Left/Right keys, but the code you provided made only one step and only in the left direction on both keys

No problem, Left/Right is enough for me.
Title: Re: Moving shape with keys
Post by: ASerge on April 29, 2018, 02:43:16 pm
No problem, Left/Right is enough for me.
Try this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.   if Key = VK_SHIFT then
  4.   begin
  5.     if GetKeyState(VK_LSHIFT) < 0 then
  6.       Shape1.Left := Shape1.Left - 15
  7.     else
  8.       if GetKeyState(VK_RSHIFT) < 0 then
  9.         Shape1.Left := Shape1.Left + 15;
  10.     Key := 0;
  11.   end;
  12. end;
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 03:16:40 pm
No problem, Left/Right is enough for me.
Try this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.   if Key = VK_SHIFT then
  4.   begin
  5.     if GetKeyState(VK_LSHIFT) < 0 then
  6.       Shape1.Left := Shape1.Left - 15
  7.     else
  8.       if GetKeyState(VK_RSHIFT) < 0 then
  9.         Shape1.Left := Shape1.Left + 15;
  10.     Key := 0;
  11.   end;
  12. end;
Thank you ASerge for your effort, but unfortunately it does the same as previously.
Title: Re: Moving shape with keys
Post by: Handoko on April 29, 2018, 03:25:30 pm
I think we got a bug.

Thank your ASerge, your code works but with some issue. I tested on Lazarus 1.8.0 64-bit Gtk2 Linux. Maybe it is a bug that only happens on Gtk2 or Linux, I haven't tested it on Windows.

This is my test code:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, LCLType, LclIntf, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Shape1: TShape;
  16.     Timer1: TTimer;
  17.     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  18.     procedure Timer1Timer(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. type
  26.   TDirection = (dirLeft, dirRight, dirNone);
  27.  
  28. var
  29.   Form1: TForm1;
  30.   Direction: TDirection = dirNone;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. { TForm1 }
  37.  
  38. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
  39.   );
  40. begin
  41.   if Key = VK_SHIFT then
  42.   begin
  43.     if GetKeyState(VK_LSHIFT) < 0 then Direction := dirLeft;
  44.     if GetKeyState(VK_RSHIFT) < 0 then Direction := dirRight;
  45.     Key := 0;
  46.   end;
  47. end;
  48.  
  49. procedure TForm1.Timer1Timer(Sender: TObject);
  50. begin
  51.   case Direction of
  52.     dirLeft:  Shape1.Left := Shape1.Left - 10;
  53.     dirRight: Shape1.Left := Shape1.Left + 10;
  54.   end;
  55.   if (Shape1.Left < -70)   then Shape1.Left := Width;
  56.   if (Shape1.Left > Width) then Shape1.Left := -70;
  57.   Direction := dirNone;
  58. end;
  59.  
  60. end.

If I change line #43, #44 to the lines below, then it only moves left:
Code: Pascal  [Select][+][-]
  1.     if GetKeyState(VK_LSHIFT) < 0 then
  2.       Direction := dirLeft
  3.     else
  4.       if GetKeyState(VK_RSHIFT) < 0 then
  5.         Direction := dirRight;

My guess, it is a bug in GetKeyState. Because on my test right shift key always generates both VK_RSHIFT and VK_LSHIFT.
Title: Re: Moving shape with keys
Post by: jamie on April 29, 2018, 03:33:35 pm
You may need to use GetKeyBoardState which retrieves all 256 key states placed in a buffer..

Look here for the example
TKeyboardState is an array of bytes but it makes it handy to use  :)
http://www.delphipages.com/forum/showthread.php?t=18108

I suppose one could do this while inside the OnKeyDown event but not sure if all will be captured.
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 04:20:02 pm
An other "issue".
Currently I'm using this code (with Left/Right keys):
   
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2.     begin
  3.        case Key of
  4.         VK_LEFT:
  5.           Shape1.Left := Shape1.Left - 15;
  6.         VK_RIGHT:
  7.           Shape1.Left := Shape1.Left + 15;
  8.       end;
  9.     end;

My problem is the latency. When I'm pressing the Left/Right key, the shape first moves only one step (15), then waits a bit, and after moves continuously.
Is it possible somehow to get instant and continuous reaction without the little pause?
Title: Re: Moving shape with keys
Post by: Handoko on April 29, 2018, 04:28:50 pm
You may need to use GetKeyBoardState which retrieves all 256 key states placed in a buffer..

Thank you jamie. If I'm not wrong it is only available on Windows, unfortunately I'm a Linux user.

My problem is the latency. When I'm pressing the Left/Right key, the shape first moves only one step (15), then waits a bit, and after moves continuously.
Is it possible somehow to get instant and continuous reaction without the little pause?

Wait, give me some minutes. I'm trying to improve the code.
Title: Re: Moving shape with keys
Post by: Handoko on April 29, 2018, 04:35:04 pm
Is it possible somehow to get instant and continuous reaction without the little pause?
That happens because you use OnKeyDown event, don't use that.

The code below should works as what you want now:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, LCLType, LclIntf, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Shape1: TShape;
  16.     Timer1: TTimer;
  17.     procedure Timer1Timer(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. type
  25.   TDirection = (dirLeft, dirRight, dirNone);
  26.  
  27. var
  28.   Form1: TForm1;
  29.   Direction: TDirection = dirNone;
  30.  
  31. implementation
  32.  
  33. {$R *.lfm}
  34.  
  35. { TForm1 }
  36.  
  37. procedure TForm1.Timer1Timer(Sender: TObject);
  38. begin
  39.   if GetKeyState(VK_LSHIFT) < 0 then Direction := dirLeft;
  40.   if GetKeyState(VK_RSHIFT) < 0 then Direction := dirRight;
  41.   case Direction of
  42.     dirLeft:  Shape1.Left := Shape1.Left - 3;
  43.     dirRight: Shape1.Left := Shape1.Left + 3;
  44.   end;
  45.   if (Shape1.Left < -70)   then Shape1.Left := Width;
  46.   if (Shape1.Left > Width) then Shape1.Left := -70;
  47.   Direction := dirNone;
  48. end;
  49.  
  50. end.

Edit:
Sorry I didn't read your post carefully. I now saw you use Left/Right keys, you should change the keys in my example to VK_RIGHT and VK_LEFT.
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 04:48:43 pm
Is it possible somehow to get instant and continuous reaction without the little pause?
That happens because you use OnKeyDown event, don't use that.

The code below should works as what you want now:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, LCLType, LclIntf, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Shape1: TShape;
  16.     Timer1: TTimer;
  17.     procedure Timer1Timer(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. type
  25.   TDirection = (dirLeft, dirRight, dirNone);
  26.  
  27. var
  28.   Form1: TForm1;
  29.   Direction: TDirection = dirNone;
  30.  
  31. implementation
  32.  
  33. {$R *.lfm}
  34.  
  35. { TForm1 }
  36.  
  37. procedure TForm1.Timer1Timer(Sender: TObject);
  38. begin
  39.   if GetKeyState(VK_LSHIFT) < 0 then Direction := dirLeft;
  40.   if GetKeyState(VK_RSHIFT) < 0 then Direction := dirRight;
  41.   case Direction of
  42.     dirLeft:  Shape1.Left := Shape1.Left - 3;
  43.     dirRight: Shape1.Left := Shape1.Left + 3;
  44.   end;
  45.   if (Shape1.Left < -70)   then Shape1.Left := Width;
  46.   if (Shape1.Left > Width) then Shape1.Left := -70;
  47.   Direction := dirNone;
  48. end;
  49.  
  50. end.

Edit:
Sorry I didn't read your post carefully. I now saw you use Left/Right keys, you should change the keys in my example to VK_RIGHT and VK_LEFT.

@Handoko: this is fantastic, I implemented it and works like the dream!
Thank you!
Title: Re: Moving shape with keys
Post by: Handoko on April 29, 2018, 04:52:23 pm
I saw you're interested in game programming. You should join the Game Contest 2018:
http://forum.lazarus.freepascal.org/index.php/topic,39495.0.html
Title: Re: Moving shape with keys
Post by: Handoko on April 29, 2018, 05:13:01 pm
For newbies, this thread in the link below is valuable if you want to learn game programming:
http://forum.lazarus.freepascal.org/index.php/topic,38136.msg258290.html#msg258290

It shows you how to build a snake game, things can be learn from there:
- Using array to represent the game world
- Game loop
- Collision detection
- Dynamic array
- TList
- Random
- Using data buffer to store keyboard input
- How to reduce flickering

The thread is very long, but it's worth especially for beginners.
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 05:16:29 pm
For newbies, this thread in the link below is valuable if you want to learn game programming:
http://forum.lazarus.freepascal.org/index.php/topic,38136.msg258290.html#msg258290

It shows you how to build a snake game, things can be learn from there:
- Using array to represent the game world
- Game loop
- Collision detection
- Dynamic array
- TList
- Random
- Using data buffer to store keyboard input
- How to reduce flickering

The thread is very long, but it's worth especially for beginners.

Great, thank you, I will study it!
Anyway, here is "my" tennis game (mostly aquired from a video):
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   StdCtrls, uplaysound, LclType, LclIntf;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     lblRestart: TLabel;
  17.     field: TImage;
  18.     lblGameOver: TLabel;
  19.     lblScore: TLabel;
  20.     playsound1: Tplaysound;
  21.     Racket: TShape;
  22.     Ball: TShape;
  23.     tmrGame: TTimer;
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure lblRestartClick(Sender: TObject);
  26.     procedure lblRestartMouseEnter(Sender: TObject);
  27.     procedure lblRestartMouseLeave(Sender: TObject);
  28.     procedure tmrGameTimer(Sender: TObject);
  29.   private
  30.     procedure initGame;
  31.     procedure updateScore;
  32.     procedure gameOver;
  33.     procedure increaseSpeed;
  34.   public
  35.  
  36.   end;
  37.  
  38. type
  39.   TDirection = (dirLeft, dirRight, dirNone);
  40.  
  41. var
  42.   Form1: TForm1;
  43.   score: integer;
  44.   speedX, speedY: integer;
  45.   step: byte = 8;
  46.   Direction: TDirection = dirNone;
  47.  
  48. implementation
  49.  
  50. {$R *.lfm}
  51.  
  52. { TForm1 }
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. begin
  56.   DoubleBuffered := True;
  57.   Randomize;
  58.   initGame;
  59. end;
  60.  
  61. procedure TForm1.lblRestartClick(Sender: TObject);
  62. begin
  63.   initGame;
  64. end;
  65.  
  66. procedure TForm1.lblRestartMouseEnter(Sender: TObject);
  67. begin
  68.   lblRestart.Font.Style := [fsBold, fsUnderline];
  69. end;
  70.  
  71. procedure TForm1.lblRestartMouseLeave(Sender: TObject);
  72. begin
  73.   lblRestart.Font.Style := [];
  74. end;
  75.  
  76. procedure TForm1.initGame;
  77. var
  78.   startPos: integer;
  79. begin
  80.   score := 0;
  81.   speedX := -4;
  82.   speedY := -4;
  83.  
  84.   startPos := ClientWidth div 2 + Random(2 * 200) - 200;
  85.  
  86.   Racket.Left := startPos - Racket.Width div 2;
  87.   Racket.Top := ClientHeight - Racket.Height - 2;
  88.  
  89.   Ball.Left := startPos - Ball.Width div 2;
  90.   Ball.Top := Racket.Top - Ball.Height - 2;
  91.  
  92.   lblGameOver.Visible := False;
  93.   lblRestart.Visible := False;
  94.   lblRestart.Font.Style := [];
  95.  
  96.   updateScore;
  97.   Cursor := crNone;
  98.   field.Cursor := crNone;
  99.   tmrGame.Enabled := True;
  100. end;
  101.  
  102. procedure TForm1.updateScore;
  103. begin
  104.   lblScore.Caption := IntToStr(score);
  105. end;
  106.  
  107. procedure TForm1.increaseSpeed;
  108. begin
  109.   if speedX > 0 then
  110.     Inc(speedX)
  111.   else
  112.     Dec(speedX);
  113.   if speedY > 0 then
  114.     Inc(speedY)
  115.   else
  116.     Dec(speedY);
  117. end;
  118.  
  119. procedure TForm1.gameOver;
  120. begin
  121.   tmrGame.Enabled := False;
  122.   lblGameOver.Visible := True;
  123.   lblRestart.Visible := True;
  124.   Cursor := crDefault;
  125.   field.Cursor := crDefault;
  126. end;
  127.  
  128. procedure TForm1.tmrGameTimer(Sender: TObject);
  129. begin
  130.   if GetKeyState(VK_LSHIFT) < 0 then
  131.     Direction := dirLeft;
  132.   if GetKeyState(VK_RSHIFT) < 0 then
  133.     Direction := dirRight;
  134.   case Direction of
  135.     dirLeft: if Racket.Left >= step then
  136.         Racket.Left := Racket.Left - step;
  137.     dirRight: if Racket.Left + Racket.Width <= ClientWidth - step then
  138.         Racket.Left := Racket.Left + step;
  139.   end;
  140.   Direction := dirNone;
  141.  
  142.   Ball.Left := Ball.Left + speedX;
  143.   Ball.Top := Ball.Top + speedY;
  144.  
  145.   //Walls
  146.   if Ball.Top <= 0 then
  147.   begin
  148.     playsound1.SoundFile := 'wall1.wav';
  149.     playsound1.Execute;
  150.     speedY := -speedY;
  151.   end;
  152.  
  153.   if (Ball.Left <= 0) or (Ball.Left + Ball.Width >= ClientWidth) then
  154.   begin
  155.     playsound1.SoundFile := 'wall1.wav';
  156.     playsound1.Execute;
  157.     speedX := -speedX;
  158.   end;
  159.  
  160.  
  161.   //Game over
  162.   if Ball.Top + Ball.Height > Racket.Top + Racket.Height div 2 then
  163.   begin
  164.     playsound1.SoundFile := 'gameover2.wav';
  165.     playsound1.Execute;
  166.     gameOver;
  167.   end;
  168.  
  169.  
  170.   //Good hit
  171.   if (Ball.Left + Ball.Width > Racket.Left) and (Ball.Left < Racket.Left + Racket.Width) and (Ball.Top + Ball.Height >= Racket.Top) then
  172.   begin
  173.     playsound1.SoundFile := 'hit.wav';
  174.     playsound1.Execute;
  175.     speedY := -speedY;
  176.     increaseSpeed;
  177.     Inc(score);
  178.     updateScore;
  179.   end;
  180. end;
  181.  
  182.  
  183. end.
Title: Re: Moving shape with keys
Post by: lainz on April 29, 2018, 05:43:19 pm
You will enter the Game Contest 2018?
https://forum.lazarus.freepascal.org/index.php/topic,39495.0.html
Title: Re: Moving shape with keys
Post by: Handoko on April 29, 2018, 05:49:40 pm
@justnewbie

Your tennis game looks much better than my first game arkanoid-clone. You should enter the game contest!

Because you didn't provide the resource files (audio, image and .lfm), it can't run as what you designed. See the image below.

Here is how you should do if you want to publish your source code here:
Copy all the files (including images and audios) in to a new folder, except: *.bak, the binary and the lib folder. Compress the folder and attach the zip file to the forum.

Alternatifly, you can use Publish Project feature in the Lazarus IDE (which is a bit technical if you never use it):
Lazarus main menu > Project > Publish
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 06:22:35 pm
LOL, I and the Game Contest ... funny! I'm a newbie, so it would be a bit bigger challenge than optimal. Maybe later!  :)
Because of the file size limit here, I uploaded THE GAME here: https://ufile.io/n4rxa (https://ufile.io/n4rxa)
Guaranteed enjoy for years! Attention: heavily addictive GAME!  :D
Title: Re: Moving shape with keys
Post by: lainz on April 29, 2018, 08:49:58 pm
There are newbies in the game contest, just check the entries.
Title: Re: Moving shape with keys
Post by: justnewbie on April 29, 2018, 11:27:27 pm
Really thank you for the kind invitations, and honestly, I'd like to participate in it. But, my knowledge is very humble and my free time is not so much currently.  :)
Title: Re: Moving shape with keys
Post by: Handoko on April 30, 2018, 06:31:48 am
By participating the contest, you will learn lots of new tricks in programming. Your program will be tested by users who use different hardware and OSes. You will learn about compatibility issue, deployment, user experience and many more.

Last year, I submitted 2 programs for the contest. I thought my programs were working good but no, I was wrong. I used TImage's built-in image loader for my glSlideshow, but now I know it has some issues when opening certain tiff files. That bug forced me to learn FPimage unit, which has better support for loading tiff files. Also an experienced OpenGL programmer suggested me to use modern OpenGL, he even rewrote my program showing how to program using it. I still have problem understanding modern OpenGL concept, but I bookmarked his posts for later studying.

The second program was a simple game created using Allegro library. It worked on my computer but not on others. Because I had not properly did the deployment. Also, an user told me that the display of my game was too small when running on his large screen monitor. That made me adding double size display feature.

See, even I have been learning graphics and game programming for years, I still learned many new things participating the contest.

It's not about to be the winner. It's about learning new things that you won't get from reading.

Your Tennis game has potential, it already has background texture and audio. If I'm allowed, I will suggest adding some random elements. For example in my arkanoid-clone, there were some objects that will cause random direction and speed if being hit, some others are for surprise, for example double even triple the balls that appear on the screen. And the bounce angle should not be constant, if it hit near the edge of the racket, it should has sharp angle. Also if you implement game state, it can have pause, demo and etc.
Title: Re: Moving shape with keys
Post by: justnewbie on April 30, 2018, 09:25:03 am
By participating the contest, you will learn lots of new tricks in programming. Your program will be tested by users who use different hardware and OSes. You will learn about compatibility issue, deployment, user experience and many more.

Last year, I submitted 2 programs for the contest. I thought my programs were working good but no, I was wrong. I used TImage's built-in image loader for my glSlideshow, but now I know it has some issues when opening certain tiff files. That bug forced me to learn FPimage unit, which has better support for loading tiff files. Also an experienced OpenGL programmer suggested me to use modern OpenGL, he even rewrote my program showing how to program using it. I still have problem understanding modern OpenGL concept, but I bookmarked his posts for later studying.

The second program was a simple game created using Allegro library. It worked on my computer but not on others. Because I had not properly did the deployment. Also, an user told me that the display of my game was too small when running on his large screen monitor. That made me adding double size display feature.

See, even I have been learning graphics and game programming for years, I still learned many new things participating the contest.

It's not about to be the winner. It's about learning new things that you won't get from reading.

Your Tennis game has potential, it already has background texture and audio. If I'm allowed, I will suggest adding some random elements. For example in my arkanoid-clone, there were some objects that will cause random direction and speed if being hit, some others are for surprise, for example double even triple the balls that appear on the screen. And the bounce angle should not be constant, if it hit near the edge of the racket, it should has sharp angle. Also if you implement game state, it can have pause, demo and etc.
Very true viewpoints, you are absolutely right in all aspects. But, the time is limited that I can take for it. Maybe later!  :-X
TinyPortal © 2005-2018