Well, I don't think Perl is best suited for that job. Everything you can do with JavaScript inside a web browser is much easier to accomplish with JavaScript than Perl. Without modules and 3rd party code, it will be impossible. Why? Because for example, if you look at all the available keywords in the Perl reference, you won't see a command that allows you to directly read the keypresses. There is a way to read a line of text from stdin, but that means the user has to press ENTER after some typing. Now, that would be a weird game if the user had to navigate it by typing commands and have to press Enter each time for that to register. You couldn't do a shooting game, because it would be too slow. By the time the user types and presses Enter, he's dead. Or you couldn't do a game where you have to navigate a maze, because each time the user must step forward, he would have to type a letter or command and press Enter. The user would have to memorize all the various commands and have super fast fingers to type it all in. It wouldn't be the same experience! In JavaScript, you can create clickable images or areas on the screen, and you can even capture the mouse position. In Perl, there is no such thing without modules. You can forget about the mouse. In JavaScript, you have builtin support for timed events which you can execute with millisecond precision. Without modules, Perl can only do that with second precision. In other words, if you want to animate something in JavaScript, you can tell the browser to wait 10ms and then do something and then wait another 10ms and do something. But in Perl, you can only tell the computer to wait a second and then do something. If your game has millisecond precision timing, it will look much more natural than if events happen at second intervals. If you look in the Perl reference, there is no command to write a pixel to the screen. You can only print text. There is no command to access the mouse. There is no builtin command to play sounds. You can print character 7 to stdout and hope it will produce a beep sound, but that's all you can do as far as creating sound. You can't play various frequencies. You can't play mp3 music without 3rd party tools.

Perl is geared toward data processing. That means reading/writing files. Reading/writing stdin and stdout. whether it's binary data or plain text. Executing other programs, capturing their output. Then finding patterns, replacing patterns. Perl is superb when it has to work with various lists and finding things in a list. Perl is a really good tool for creating a program that generates a summary, an dynamic HTML page, a conversion program that reads one type of file and writes another type of file. Perl is good with printing readable plain text to the screen.

In games, you typically need to generate real-time graphic output, capture mouse clicks and mouse position and keyboard presses, wait for a few milliseconds, then do something, load wav or mp3 files, play sounds, do tons of calculations, load various pictures, manipulate those pictures in some way then place them on the screen. After the game is over, then load the next level or whatever. So, there is need to load a new file from the server, and perhaps push the current state of the game back to a server. It can get really complicated. I don't know what kind of game you are trying to create, but all the things I have listed here you cannot do in Perl without modules or 3rd party code. :[ Mmm.. with Perl, you could read various image formats without modules if you write your own decoding algorithms, but that's not very ideal. When you want to write a game, you want to focus on the action, not start from the lowest level. I would suggest that you look up XBASIC and PureBASIC and LibertyBASIC and see what you think. Those three programming languages make it really easy to write simple games...

Now, I am going to sit back and watch all of them downvotes come, but everything I have said is the truth.


In reply to Re: game programming by harangzsolt33
in thread game programming by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.