Recent

Author Topic: Would Lazarus help me out here?  (Read 5553 times)

486DX2

  • Newbie
  • Posts: 5
Would Lazarus help me out here?
« on: November 02, 2017, 10:28:54 pm »
First post for me, so I guess: hi all!

Big warning up front: I'm not particularly good at coding (understatement!).
However, I would very much appreciate your opinion on the following.

A bit of essential background (I'll keep it as short as possible):

Learned Turbo Pascal when I was a kid (when I was 10-12 years?). Now 20+ years later after not doing anything with that, I find myself in a very demanding job
in Science, and for the last 2 years somehow, I discovered that writing random programs in TP is very relaxing to me; don't ask me why, I'm weird like that.

I'm currently working on making a first-person 3D maze game where the 'player' can walk around in (in a grid-like fashion). It's SUPER basic, trust me, and all of
you will probably laugh for a week when you'd see the actual code, but I don't care  ;D

It's basically a 3D perspective made by drawing lines and using the FloodFill procedure from the Graph unit  (yes, this is old-school DOS, using an emulator and
a 640x480x16 color mode).

The trouble is: it's really slow and suffers a lot from flickering when the screen refreshes (ClearDevice) whenever the player takes a (grid-based) move. Hence,
I've been looking for options to speed this up.

My big question is: Should I investigate Lazarus as an option? I don't have much time and I probably won't be able to learn everything Lazarus has to offer
(which looks absolutely fantastic btw!!), but..... can I quickly switch to Lazarus to make this happen?


Thanks so much for your time, and best wishes,
486DX2
« Last Edit: November 02, 2017, 10:33:14 pm by 486DX2 »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: Would Lazarus help me out here?
« Reply #1 on: November 02, 2017, 10:37:41 pm »

You could use Lazarus as editor for a normal Free Pascal program that uses some graphics API like opengl.

There is some learning curve there though.

486DX2

  • Newbie
  • Posts: 5
Re: Would Lazarus help me out here?
« Reply #2 on: November 02, 2017, 10:49:50 pm »
Hi marcov,

Thanks for your quick reply. I don't mind some kind of a learning curve, as long as I don't have to redesign the whole thing from scratch,
e.g. can I make use of the same kind of procedures as specified in the Graph unit I'm using now?

Bart

  • Hero Member
  • *****
  • Posts: 5715
    • Bart en Mariska's Webstek
Re: Would Lazarus help me out here?
« Reply #3 on: November 02, 2017, 10:54:10 pm »
I hope you are not doing this on an actual 486DX2?

Bart

486DX2

  • Newbie
  • Posts: 5
Re: Would Lazarus help me out here?
« Reply #4 on: November 02, 2017, 10:58:16 pm »
Haha, nah, it's just my most favorite pc of all time somehow, hence I often use it as my nick  :D )

Bart

  • Hero Member
  • *****
  • Posts: 5715
    • Bart en Mariska's Webstek
Re: Would Lazarus help me out here?
« Reply #5 on: November 02, 2017, 11:03:54 pm »
Well, I'ld say: start playing with Lazarus.
You can write console applications with it, the IDE is great, especially the codetools.

Try to program some basic GUI applications.
There are plenty of (Delphi) basic tutorials out there.

If you program just for fun (like me) and like Pascal (like me), you'll like it a lot.

Bart

486DX2

  • Newbie
  • Posts: 5
Re: Would Lazarus help me out here?
« Reply #6 on: November 02, 2017, 11:09:17 pm »
Thanks Bart, that sounds quite promising as I DO like to program just for fun.

It's just the lack of time that refrains me from learning a complete different programming language,
but I'll look into it

Bart

  • Hero Member
  • *****
  • Posts: 5715
    • Bart en Mariska's Webstek
Re: Would Lazarus help me out here?
« Reply #7 on: November 02, 2017, 11:09:32 pm »
Haha, nah, it's just my most favorite pc of all time somehow, hence I often use it as my nick  :D )

It was my most expensive computer ever (ƒ 8000, roughly € 3500, see https://www.flyingsheep.nl/computer_nostalgie.htm).
It came without a CDROM, I bought that seperately some time later.

TP6 was ligthening fast on it.

Bart

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: Would Lazarus help me out here?
« Reply #8 on: November 02, 2017, 11:11:09 pm »
Well, you can do a lot of cool stuff with Lazarus like this https://www.youtube.com/watch?v=HW0GoyMhWSI
Thou you'll have to get acquainted with some Engine like Castle Game Engine (I used it in the video), BGRA, GLScene or something like that.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Bart

  • Hero Member
  • *****
  • Posts: 5715
    • Bart en Mariska's Webstek
Re: Would Lazarus help me out here?
« Reply #9 on: November 02, 2017, 11:23:51 pm »
It's just the lack of time that refrains me from learning a complete different programming language,
but I'll look into it

That's the point.
It is NOT a different language.
It has just been extended a little.

You need to get adjusted to the fact that GUI programs are event-driven.
There is no lineair program flow.
User press buttons, click on treeviews etc. and you "just" write the code to respond to that user interaction.
That code you write is more often than not just plain pascal.

The preverbial "Hello World" in a GUI program would be like this:

Code: Pascal  [Select][+][-]
  1. ...
  2. procedure TForm1.Button1Click(Sender: TObject);
  3. begin
  4.   ShowMessage('Hello World');
  5. end;
  6. ...
  7.  

Making this program requires you to do the following:
Menu->Project->New Project: click OK
Select a TButton form the main compomentbar.
Click on the form to put the Buttonn on it
Double click on the button
This will appear:

Code: Pascal  [Select][+][-]
  1. ...
  2. procedure TForm1.Button1Click(Sender: TObject);
  3. begin
  4.  
  5. end;
  6. ...
  7.  

Just write the ShowMessage() code inside that procedure.
Hit the F9-Key
This will build the program and run it inside the debugger.
Click on the button (with caption "Button1") and the message will show up.

It's called RAD: Rapid Application Development.

Compare that to doing the same with TP's TurboVision (I still remember the nightmare to write menu structures with that).

Bart

486DX2

  • Newbie
  • Posts: 5
Re: Would Lazarus help me out here?
« Reply #10 on: November 02, 2017, 11:25:36 pm »
@Eugene Loza, that looks absolutely amazing and way more advanced than I had in mind. It's probably take me quite learn it all huh? Oh well, perhaps I just need patience then  :)

@Bart, happy to hear you once owned one yourself. But yeah, these puppies were super expensive , still worth it though, so quick for its time!

munair

  • Hero Member
  • *****
  • Posts: 887
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Would Lazarus help me out here?
« Reply #11 on: November 03, 2017, 06:16:03 am »
I hope you are not doing this on an actual 486DX2?

Bart

Actually FPC would do just fine on such computer. I plan to install the compiler on my 386SX PC. I bought it back in 95 for ƒ500,- and just cannot get myself to throw it away.  :D
« Last Edit: November 03, 2017, 10:19:25 am by Munair »
It's only logical.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: Would Lazarus help me out here?
« Reply #12 on: November 03, 2017, 07:13:12 am »
Quote
It's probably take me quite learn it all huh?
Not that it'll take too long... In 2012 me too - I first started "returning to Pascal" after last TurboPascal experience in 2000 and I still have a lot of troubles with my obsolete/fragmentary knowledge of Pascal (I didn't even know the difference between "object" and "class"). It took me just 2 years to learn why my SomeClass.Create always raises a SIGSEGV :) Apart from such and similar cultural shocks/barriers it is relatively simple to and you could get started within a week without any hard work.
Just be patient to struggle stupid "Why Extract raises a SIGSEGV", "Why do I get an exception 'found' if everything went smoothly" or "I don't get it, what is Children[0] and why it also has its Children[0]" and "What on the Earth is Create(true)" for some time.
« Last Edit: November 03, 2017, 07:16:41 am by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Handoko

  • Hero Member
  • *****
  • Posts: 5537
  • My goal: build my own game engine using Lazarus
Re: Would Lazarus help me out here?
« Reply #13 on: November 03, 2017, 07:56:29 am »
My big question is: Should I investigate Lazarus as an option? I don't have much time and I probably won't be able to learn everything Lazarus has to offer

Lazarus really has lots of things to offer. You should pick the graphics/games engine properly:
http://wiki.freepascal.org/Game_Engine
http://wiki.freepascal.org/Graphics_libraries

Castle Game Engine should be a good choice if you want to build 3D games. It is a frame work, hard to start with but has lots of ready to use tools for developing games, it even have a tool to help you publish the games to Android platform. I saw @Eugene Loza build some good quality short games using it.

GLScene is a 3D frame work for general purposes. The code has some minor issues on Linux but they're improving it.

nxPascal is simpler but fully capable for 3D too. You can read more about it here:
http://forum.lazarus.freepascal.org/index.php/topic,35313.msg253469.html#msg253469

If you like doing the graphics yourself you can consider to use TOpenGLControl. It is a bit hard because good OpenGL tutorials usually available for C/C++ language only.

If you're interested in 2D games, you can try: Allegro.pas, SDL, ZenGL, BGRABitmap.

Have fun!
« Last Edit: November 03, 2017, 08:36:33 am by Handoko »

Thaddy

  • Hero Member
  • *****
  • Posts: 19139
  • Glad to be alive.
Re: Would Lazarus help me out here?
« Reply #14 on: November 03, 2017, 09:53:30 am »
for 2D don't forget Box2D which is also available for Pascal and very easy to use.
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018