I'm posting this in order to help anyone with a similar problem.
Check out SDL meets free pascal tutorial. SDL has much better functions that allow you to avoid key delays, has fast graphics drawing, display and handling, and better key events handling, and a sound mixer to play music and sound effects. Basically it is a much more advanced graphics and sound API and has better units than graph and crt with which you cannot achieve the same level of performance regarding game programming today. So I am learning SDL. I have solved the key delay problem and can play music and have sound effects at the same time. Handling pixels however is a bit more complex with sdl than with the graph unit but you get used to it quickly and you don't have to worry about flickering because the sdl_flip(psdl_surface) function elliminates that. I am currently trying to get the function sdl_getrgb to work in order to store the rgb values of each pixel on the screen in a text file so I can load them when needed in my game. In other words learning sdl for free pascal enables you to make 2d games equivalent to commercial 2d games available today. The graph and crt units are just too outdated to provide the same level of 2d gaming today. You can stil make a very decent game with the graph and crt units though but it will be near impossible to have the game handle real-time animation wherein you are controlling a character that can react in real time to enemies like in the zelda games. This being because the crt unit has the typematic delay problem and the graph unit is simply too slow at drawing primitives (circle, pixel, ellipse, line, etc.) and coloring them, unless you draw all the primitives you need to a active page and then store each of them in their own size:=imagesize(x,x1,y,y1) and getimage(x,x1,y,y1,pointer^) and then display each image quickly to visual page using putimage(x,y,pointer^,xorput) but i think the problem displaying graphics that way with the graph unit is that there is only so many part of the image you can store then the unit will run out of graphics storage memory, not to mention putimage is too slow and will cause flickeing (double buffering cannot be done properly because you cannot copy and paste an image size of more than 64k which means you will have to copy from your back buffer page to your visual page in sections which will give an effect of screen tearing). The other problem also with the graph unit is that you cannot draw primitives outside of the visual screen area. With sdl you can. This makes scrolling backgrounds a lot faster and easier and much more straight forward. However, you can still make great turn based games whether rpg with turn-based combat or action rpgs like zelda. Except for the latter it will be turn based combat. sdl will allow for real time combat. Nevertheless, with the graph and crt unit you can still make great games especially turn based rpgs where the player will not be the wiser. The only thing will be typematic delays and sound not being able to play music files with your game, only being able to use sound effects.
It took me 2 days to learn sdl so give it a go, plus I was busy working during those 2 days. I chose sdl for free pascal because I am fluent with the turbo pascal language, but if I were you I would learn c++ and check sdl tutorials for c++. You also need to get the exact dll files to enable use of sdl within the compiler whether free pascal or c++. If the tutorial says you need sdl.dll file don't get the sdl2.dll file it won't work although it is the latest version. You need to get the exact file mentioned in the tutorials. Do a search on google, that's how I found them one by one.
15 Replies - 1189 Views - Last Post: 27 September 2013 - 07:35 AM