Recent

Author Topic: Is it feasible to display a tiled game on the canvas?  (Read 7661 times)

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: Is it feasible to display a tiled game on the canvas?
« Reply #15 on: March 14, 2020, 02:07:25 am »
Doh, I'll dust off my Linux laptop in the morning and check it out!
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Is it feasible to display a tiled game on the canvas?
« Reply #16 on: March 14, 2020, 02:55:52 am »
Don't use canvas for making games. Last time I tried was really slow.

And also the game made by furious programming was not working on macOS, I tested it, so it works only on Linux and Windows.

Modern PC even cheap ones has graphic card, integrated or something else, so why keep using canvas for making games?

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: Is it feasible to display a tiled game on the canvas?
« Reply #17 on: March 14, 2020, 02:38:11 pm »
It's just about finding the right tool for the job. I don't know if you're familiar with roguelike games but the major ones (Nethack, ADOM, Sil) all have a version that runs directly from the console. There are no animations, layered graphics or sound. The gameplay comes from resource management and tactical combat so most features of modern graphics libraries are unnecessary. In fact, slow is good  :D

When I decided to use a mixture of ASCII and tiled graphics for the display I looked into Curses, BearLibTerminal and SDL before deciding on SDL as there are some great Free Pascal / SDL2 tutorials online.
Ultimately though, if I can get the canvas version working it will be a lot easier to distribute for Windows and Linux users as a standalone binary. macOS using roguelike players are such a niche within a niche that I'm not currently targeting those users.
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Is it feasible to display a tiled game on the canvas?
« Reply #18 on: March 14, 2020, 03:01:50 pm »
Well then I suggest you to do a web game is easier to distribute and for sure will work on all platforms.

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Is it feasible to display a tiled game on the canvas?
« Reply #19 on: March 14, 2020, 04:29:22 pm »
@CyberFilth

Don't limit yourself on only 1 tool. Keep trying new things and push your limits.

Writing games is the goal but there are many types of people who write games. If you just want to write games, as much as you can you should use the tools specialized for game creation. Game builder is what you need. Some people call game builder as game engine but in my opinion they're different. If you also enjoy programming, you should choose a good language + framework or game engine + graphics engine. But if you like programming, graphics, solving problems and also enjoys game, do as what I'm doing. Build the game builder yourself.

The very best game builder I strongly recommend is Godot:
https://godotengine.org/

Godot can build 2D, 3D, desktop, web, mobile, and a lot of countless features. I was amazed how easy it can cross compile to other targets. I downloaded their Android binary exporter (I don't remember what exactly it is called) and set the project target. Press build and wait for some minutes, the example that run on Linux then now was an apk that can be run on Android with zero source code modification. Something like CodeTyphon but even better. You may not believe, such great software is open source which means it is free.

If you want to write games for money, you should use the one that has good reputation. So you can get freelance or full time job easily. These two are the most famous as far as I know:
- Unreal Engine
- Unity

But if you enjoy programming, money is not the goal and you have time, then pick one or some game/graphics engine/library from the list and start building your game:
https://wiki.freepascal.org/Game_Engine
https://wiki.freepascal.org/Graphics_libraries
https://wiki.freepascal.org/Game_framework

If you enjoy good community support, you may want to try FreeBASIC. It has better graphics performance without using third party libraries. The language is relatively easy to learn. It can use/import C/C++ libraries easily. Lots of people there using it for building games - well, more suitable - programming games. The community talks a lot about game programming.

One sure thing is - try as much as you can before you finally decide which one you want to use seriously.

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: Is it feasible to display a tiled game on the canvas?
« Reply #20 on: March 14, 2020, 04:44:43 pm »
Quick link to a game I made in Godot, https://github.com/cyberfilth/Ashgard-Keep
And one I wrote in Java, https://github.com/cyberfilth/TrollCavern

I'm a Java developer in my day job so tooling about with roguelikes is just a hobby. Implementing gameplay mechanics that I'd like to see.
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Is it feasible to display a tiled game on the canvas?
« Reply #21 on: March 14, 2020, 04:59:03 pm »
Your Ashgard Keep looks good.
Any reason you don't keep using Godot?

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: Is it feasible to display a tiled game on the canvas?
« Reply #22 on: March 14, 2020, 05:14:53 pm »
If I take part in a Game Jam or something similar I'd always use Godot. It's an amazing engine.
Half of the fun of coding in my spare time though is being able to play around with game AI, Field of View algorithms etc so I end up with a complete game, no matter how small, where I understand exactly what every line of code does.

It's the coding equivalent of building model trains I guess  :D
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Is it feasible to display a tiled game on the canvas?
« Reply #23 on: March 14, 2020, 05:33:34 pm »
 :) Good to meet someone who has passion writing code here.

furious programming

  • Hero Member
  • *****
  • Posts: 858
Re: Is it feasible to display a tiled game on the canvas?
« Reply #24 on: March 21, 2020, 11:57:36 pm »
Good job @CyberFilth, now the game is working excellent on Windows — Task Manager shows at most 1% CPU usage when walking on the maze (but most of the time 0%). The game runs at such a speed and takes up as few resources as it should. 8)

The only problem is the mess in the code. You use a lot of global variables and declare a lot of global routines instead of wrapping logic in small classes. If this game from the attachment is not just a PoC, then you still need to work on the code.

And also the game made by furious programming was not working on macOS, I tested it, so it works only on Linux and Windows.

Yes, but not because the game is broken, but because I had neither the time nor the desire to fight this stupid system. I do not have access to devices with this system and I do not intend to buy one. In Poland, Apple devices are much, much less popular than those with Windows (mainly because they are much more expensive), so even borrow is not so much from whom.

But all you need to do to make Deep Platformer work on macOS is to customize the code that uses ScanLine to meet the requirements of this system. Everything else works under Windows and Linux, so it will work (or at least should) on macOS. Source code is open, so... you know what to do. 8-)
« Last Edit: March 22, 2020, 12:21:40 am by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Is it feasible to display a tiled game on the canvas?
« Reply #25 on: March 22, 2020, 12:20:01 am »
Thanks but I'm not interested right now. Your game is good, but I keep my opinion about canvas based games.

furious programming

  • Hero Member
  • *****
  • Posts: 858
Re: Is it feasible to display a tiled game on the canvas?
« Reply #26 on: March 22, 2020, 12:25:25 am »
I agree with you about using Canvas to create games. That's why I don't call my project a “game”, but a technological demo, and I'm not suggesting anyone to follow this design. It was a project mainly for fun and to prove that it can be done, but nothing more.

Ops, I did off-top, forgive me.
« Last Edit: March 22, 2020, 12:27:02 am by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Is it feasible to display a tiled game on the canvas?
« Reply #27 on: March 22, 2020, 07:28:45 am »
Lainz, Furious programming,
What else can be used for drawing instead of canvas?

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Is it feasible to display a tiled game on the canvas?
« Reply #28 on: March 22, 2020, 01:28:16 pm »
Lainz, Furious programming,
What else can be used for drawing instead of canvas?

Here we're talking about games, so for making a game you can use textures in opengl / vulkan / directx / metal for example.

furious programming

  • Hero Member
  • *****
  • Posts: 858
Re: Is it feasible to display a tiled game on the canvas?
« Reply #29 on: March 22, 2020, 04:16:55 pm »
@Zoran — if we want to create a full-fledged game, we should use what has been prepared for games. No-one normally writes games that use LCL, because native Canvas is slow and has huge restrictions on OpenGL or DirectX. In addition, LCL does not support the playback of many sounds at once, which is very important in the case of games. Of course, on Windows we can use GDI+ or DirectDraw, and use for example BASS to handle sound, but it's still a bad idea.

Depending on the requirements, you can use the API like Allegro and the game engine to write yourself, or use, for example, ZenGL and have the game engine included. Both solutions give the opportunity to use hardware acceleration, give access to huge functionality, provide support for many platforms and allow to facilitate and accelerate work. And there are many APIs and game engines available — there is plenty to choose from.

Canvas is good for creating visual components, but it is difficult to do something more demanding with its use.
« Last Edit: March 22, 2020, 04:21:45 pm by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

 

TinyPortal © 2005-2018