Recent

Author Topic: Adding simple image display to a pascal game  (Read 3476 times)

dennis1960

  • Newbie
  • Posts: 1
Adding simple image display to a pascal game
« on: March 23, 2015, 03:37:44 am »
Hi all,

I've written a baseball game that runs in a simple text only window (I think it's technically called a command window).  I'd like to add the ability to also popup a second graphics window that I can display images on to complement the game logic.  For example, when my game announces a new batter has come to the plate in the text/cmd window, I'd like to also popup a 2nd window that I can display an image of the pitcher and batter on.  I've been researching for a few days and can't figure out how to do this, or if it's even possible! 

What would be fantastic would be if someone could point me to some very simple code that I can embed in my pascal game to display an image on this 2nd graphics window.

My current environment:
Lazarus 1.2.6
FPC 2.6.4
Windows 8

Thanks!
Dennis

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Adding simple image display to a pascal game
« Reply #1 on: March 23, 2015, 05:42:46 am »
Open demos folder, there are many graphical games there

Eugene Loza

  • Hero Member
  • *****
  • Posts: 663
    • My games in Pascal
Re: Adding simple image display to a pascal game
« Reply #2 on: March 23, 2015, 09:21:09 am »
For a pop-up window create a form. You may wish to set borderstyle to bsnone.
Then fill the whole form with a TImage object (from the palette).
Then create a temporary TJPEG object to load the image from the file.
And finally:
form2.image1.canvas.copyrect... from the loaded TJPEG
form2.show
and form2.hide ontimer or onclick depending on the idea.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

 

TinyPortal © 2005-2018