Recent

Author Topic: Showing off what my 7 year old did with Lazarus!  (Read 6282 times)

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Showing off what my 7 year old did with Lazarus!
« on: October 19, 2021, 02:42:09 am »
I know... this is silly and pointless for most here.  BUT, i feel the need to share it anyway!  She is proud of it, understood and figured out some of the code... and she is loving this stuff so far!  Lazarus is going to be part of our at home school routine.
 :D

She wants to make it do colors next.



(Mods, no hard feelings if you remove this post as not being useful to community.  I get it)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Showing off what my 7 year old did with Lazarus!
« Reply #1 on: October 19, 2021, 02:44:56 am »
Great! Reminds me of the Etch-A-Sketch I had when a kid many moons ago.

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Showing off what my 7 year old did with Lazarus!
« Reply #2 on: October 19, 2021, 02:57:31 am »
She is proud of it
And I hope you're proud of her.  I'd say that's impressive considering it's from a 7 year old.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Showing off what my 7 year old did with Lazarus!
« Reply #3 on: October 19, 2021, 03:21:45 am »
Nice!
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Showing off what my 7 year old did with Lazarus!
« Reply #4 on: October 19, 2021, 03:28:39 am »
She is proud of it
And I hope you're proud of her.  I'd say that's impressive considering it's from a 7 year old.

Yes, I AM VERY proud of her.  Her excitement too was awesome!  Some day she may be an amazing programmers who got her start with Lazarus!  To be clear, she didn't write the code all on her own.  We both read about functions, learned and tried together.  Its a very fun project so far.  I am hoping my younger daughter will get excited about this stuff as well. 

Her very first program I can confidently say beats any of the Hello World first programs!   :D

And thanks to all of the Lazarus/FPC developers for your hard work on this project! 

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Showing off what my 7 year old did with Lazarus!
« Reply #5 on: October 19, 2021, 08:05:17 am »
i feel the need to share it anyway!

I am glad you did. She is obviously smart.

Great! Reminds me of the Etch-A-Sketch I had when a kid many moons ago.

+1

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Showing off what my 7 year old did with Lazarus!
« Reply #6 on: October 19, 2021, 09:20:20 am »
(Mods, no hard feelings if you remove this post as not being useful to community.  I get it)
The mods will not even consider removing it.... :) ;D :-*

Reminds me the other way around: my mother, at age 72 then wrote her own contacts/address book in-Delphi - Object Pascal. (sadly she recently died at age 90).

That is just to show age does not matter. What does matter is the programming language.

Top Job!!!
« Last Edit: October 19, 2021, 09:24:05 am by Thaddy »
Specialize a type, not a var.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Showing off what my 7 year old did with Lazarus!
« Reply #7 on: October 19, 2021, 09:34:43 am »
Well done that young lady! (And well done parents as well.)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Showing off what my 7 year old did with Lazarus!
« Reply #8 on: October 19, 2021, 04:03:08 pm »
Move to "Third party"  O:-)

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Showing off what my 7 year old did with Lazarus!
« Reply #9 on: October 19, 2021, 04:11:18 pm »
Specialize a type, not a var.

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Showing off what my 7 year old did with Lazarus!
« Reply #11 on: October 19, 2021, 04:20:05 pm »
NO!

And there's the grumpy old man again...

Bart

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Showing off what my 7 year old did with Lazarus!
« Reply #12 on: October 19, 2021, 04:29:12 pm »
So tonight we are gonna work on making the arrow keys function a little more proper.  We were able to use the keypress event of the form to simple adjust the spinedits... which the spinedits onchange currently calls the drawing points.  But she wants it to be able to accept pressing 2 arrow keys at once to draw a diagonal line for example.  So I am currently looking for how to go about that.  So I guess that will be tonights lesson for us both.   :D  I have a feeling though that processing 2 keys at once is gonna add a lot of complexity for her to understand.  For me too!  lol

If it is too complicated we will work on selecting colors with a color picker component.  That should be simple enough to keep her interested and learning.   :D

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Showing off what my 7 year old did with Lazarus!
« Reply #13 on: October 19, 2021, 05:37:51 pm »
So tonight we are gonna work on making the arrow keys function a little more proper.  We were able to use the keypress event of the form to simple adjust the spinedits... which the spinedits onchange currently calls the drawing points.  But she wants it to be able to accept pressing 2 arrow keys at once to draw a diagonal line for example.  So I am currently looking for how to go about that.  So I guess that will be tonights lesson for us both.   :D  I have a feeling though that processing 2 keys at once is gonna add a lot of complexity for her to understand.  For me too!  lol

If it is too complicated we will work on selecting colors with a color picker component.  That should be simple enough to keep her interested and learning.   :D

So i did a little reading... and i think i need to track the key down and key up events.  and I am thinking of using a timer that basically moves the drawing point.  I am thinking this may be the simplest way to go.  hmmmm.... then the timer interval can be set to adjust drawing speed i suppose.  Unless I am missing an more obvious simple solution please let me know.  Gotta keep it simple for a child.  And simple for my adult-child brain.   ;)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Showing off what my 7 year old did with Lazarus!
« Reply #14 on: October 19, 2021, 06:53:19 pm »
I think the simplest solution would be to use only two arrow keys (say Left and Right) in combination with two modifier keys (say Shift for Up and Ctrl for Down).
This means you can read all the information from a single KeyDown call.
However, if you want to try to intercept successive keystrokes, the following unit (to my surprise) works most of the time. Its accuracy does depend on the keyboard, and the typist's skill, and not having a fast keyboard repeat rate.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, Forms, LazLogger;
  9.  
  10. const
  11.  
  12.   ArrowKeys: set of Byte = [37, 38, 39, 40];
  13.   Diagonals: set of Byte = [0, 74, 76, 154];
  14.  
  15. type
  16.  
  17.   TDiagonal = (dNone, dUpLeft, dUpRight, dDownLeft, dDownRight);
  18.  
  19.   TForm1 = class(TForm)
  20.   private
  21.     arr: array[1..2] of Byte;
  22.     even: Boolean;
  23.     function AddedDiagonalKey(aKey: Word; out diagonal: TDiagonal): Boolean;
  24.   protected
  25.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  26.   end;
  27.  
  28.   function DiagonalToStr(aDiagonal: TDiagonal): String;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. function DiagonalToStr(aDiagonal: TDiagonal): String;
  36. begin
  37.   WriteStr(Result, aDiagonal);
  38.   Delete(Result, 1, 1);
  39. end;
  40.  
  41. {$R *.lfm}
  42.  
  43. { TForm1 }
  44.  
  45. function TForm1.AddedDiagonalKey(aKey: Word; out diagonal: TDiagonal): Boolean;
  46. var
  47.   tmp: Int64;
  48. begin
  49.   if aKey > High(Byte) then
  50.     begin
  51.       Diagonal := dNone;
  52.       Exit(False);
  53.     end;
  54.   if even then arr[2] := Byte(aKey)
  55.   else arr[1] := Byte(aKey);
  56.   even := not even;
  57.   tmp := arr[1] * arr[2];
  58.   Dec(tmp, 1406);
  59.   Result := (arr[1] <> arr[2]) and (arr[1] in ArrowKeys) and (arr[2] in ArrowKeys) and
  60.             (Byte(tmp) in Diagonals);
  61.   case Result of
  62.     True: case tmp of
  63.             0:   diagonal := dUpLeft;
  64.             74:  diagonal := dDownLeft;
  65.             76:  diagonal := dUpRight;
  66.             154: diagonal := dDownRight;
  67.           end;
  68.     False: diagonal := dNone;
  69.   end;
  70. end;
  71.  
  72. procedure TForm1.KeyDown(var Key: Word; Shift: TShiftState);
  73. var
  74.   diagonal: TDiagonal;
  75. begin
  76.   inherited KeyDown(Key, Shift);
  77.   case AddedDiagonalKey(Key, diagonal) of
  78.     True:  DebugLn(['diagonal key combination ',DiagonalToStr(diagonal)]);
  79.     False: DebugLn('non-diagonal key combination');
  80.   end;
  81. end;
  82.  
  83. end.


 

TinyPortal © 2005-2018