Fast 2D graphics for games and simulation

Creating Games? Developing something for fun?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
Arvin
Posts: 1
Joined: Thu Feb 16, 2017 9:47 pm
Location: Norway

Fast 2D graphics for games and simulation

Post by Arvin » Tue Aug 07, 2018 4:53 pm

I'm using Livecode to prototype a game concept where I require up to a thousand or more of tiny sprites moving around smoothly. A bit like particle physics.

Livecode itself is very slow handling many sprites but up to now I'm getting by with a trick of using the anchors of invisible polygons as sprites. I change the shape of a few polygons to move over a thosand anchors/sprites with reasonable speed. But it is a bit messy and the sprites can't change appearance easily.

The best would be to have a 2D graphics engine with hardware accelerated sprite support. I don't really need a full physics engine with particle simulation, collisions detection etc. What are the best options?

- Is Animation Engine good for this, is it faster than that the built in graphics engine?
- Are there other libraries/LC/ builder/widgets/extensions that can do fast 2D graphics?
- Do I get faster speed if the simulation (2D canvas with sprites) is coded in LC Builder, e.g. as a widget?
- Other ways of doing this in Livecode, or do I need to look at other gaming platforms like Unity?

I'm quite new to Livecode, currently using LC 8.1.9.

Thanks,
Arvin

bogs
Posts: 2190
Joined: Sat Feb 25, 2017 10:45 pm

Re: Fast 2D graphics for games and simulation

Post by bogs » Tue Aug 07, 2018 6:53 pm

I'm far from an expert in this area, so I'll be interested in seeing some answers myself from the more experienced.
Arvin wrote:
Tue Aug 07, 2018 4:53 pm
I require up to a thousand or more of tiny sprites moving around smoothly
My take up till now is that with Lc being single threaded in execution, this will never happen. [*1]Moving 5 small circles is possible, but even with lockScreen, lockMoves, etc that is really pushing the limits.

Having said that, though, I also don't use the latest and greatest versions, nor do I have the most experience in this area as I said, so I look forward to the answers you receive too.
_______
[*1]At least it seems to me, I used a simple technique for doing exactly that on a splash screen, it is almost painful to watch execute.
Image

AndyP
Posts: 367
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Fast 2D graphics for games and simulation

Post by AndyP » Wed Sep 12, 2018 6:38 pm

You might be better off doing this with the browser widget and a javascript physics engine?
Andy Piddock

http://2108.co.uk/tinyide/ - TinyIDE gives you more space to develop your ideas

http://2108.co.uk/script-editor-themer/ Script Editor Themer - Your code has never looked so good

My software never has bugs. It just develops random features

Klaus
Posts: 10327
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Fast 2D graphics for games and simulation

Post by Klaus » Wed Sep 12, 2018 6:42 pm

Hi all,
AndyP wrote:
Wed Sep 12, 2018 6:38 pm
You might be better off doing this with the browser widget and a javascript physics engine?
sounds like the way to go, at least until LC has implemented the rest of the SKIA library: https://skia.org

Best

Klaus

capellan
Posts: 505
Joined: Wed Aug 15, 2007 11:09 pm
Contact:

Re: Fast 2D graphics for games and simulation

Post by capellan » Wed Sep 12, 2018 8:28 pm

Klaus, Could you imagine LiveCode with DTP features
like type kerning & tracking and fractional line widths.
Skia offers more, much more, than DTP features... :D

https://skia.org/user/api/SkPaint_Reference

Klaus
Posts: 10327
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Fast 2D graphics for games and simulation

Post by Klaus » Wed Sep 12, 2018 8:34 pm

If I want kerning etc., I will buy InDesign, XPress or the new Affinity Publisher! :D

I meant more the 2D animation capabilities like a Physics Engine etc. of SKIA and not that LC will implement EVERYTHING (which is really MUCH) that SKIA provides.

ClipArtGuy
Posts: 184
Joined: Wed Aug 19, 2015 4:29 pm

Re: Fast 2D graphics for games and simulation

Post by ClipArtGuy » Thu Sep 13, 2018 12:37 am

bogs wrote:
Tue Aug 07, 2018 6:53 pm
Moving 5 small circles is possible, but even with lockScreen, lockMoves, etc that is really pushing the limits.
Check out this game, it seems to work fairly well moving more than 5 things around at time.
This stack was originally posted in another thread, but both the video and stack appear to be dead links.
I've uploaded the stack here, it can be downloaded directly or launched from the message box:

Code: Select all

open stack URL "http://www.probablyusererror.com/ShooterBlankDB.livecode"

capellan
Posts: 505
Joined: Wed Aug 15, 2007 11:09 pm
Contact:

Re: Fast 2D graphics for games and simulation

Post by capellan » Thu Sep 13, 2018 2:36 am

Hi Klaus,
If I want kerning etc., I will buy InDesign, XPress or the new Affinity Publisher! :D
Or you could pay (until September 24), just 25 dollars for
the Complete Suite of Xara Design Software:
https://www.humblebundle.com/software/m ... le_index_2
I meant more the 2D animation capabilities like a Physics Engine etc. of SKIA and not that LC will implement EVERYTHING (which is really MUCH) that SKIA provides.


Now that you mention Physics Engine, I just remembered too
Franklin 3D 1.7.1 (Irrlicht Engine) for LiveCode and
Animation Engine by Malte Brill.

Al

Klaus
Posts: 10327
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Fast 2D graphics for games and simulation

Post by Klaus » Thu Sep 13, 2018 9:23 am

Hi Al,
capellan wrote:
Thu Sep 13, 2018 2:36 am
Hi Klaus,
If I want kerning etc., I will buy InDesign, XPress or the new Affinity Publisher! :D
Or you could pay (until September 24), just 25 dollars for
the Complete Suite of Xara Design Software:
https://www.humblebundle.com...
I wouldn't even if I'd be Windows guy, but I have no need for that. :D


Best

Klaus

SparkOut
Posts: 1793
Joined: Sun Sep 23, 2007 4:58 pm

Re: Fast 2D graphics for games and simulation

Post by SparkOut » Thu Sep 13, 2018 10:14 am

Malte's Animation Engine is fantastic and gives many invaluable functions to make it simpler to produce animated results.
Unfortunately in this context, it's written in LC script and not part of the engine, so there is no performance benefit. An engine-based animation library would be great.

Klaus
Posts: 10327
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Fast 2D graphics for games and simulation

Post by Klaus » Thu Sep 13, 2018 10:39 am

capellan wrote:
Thu Sep 13, 2018 2:36 am
Now that you mention Physics Engine, I just remembered too Franklin 3D 1.7.1 (Irrlicht Engine) for LiveCode...
Ah, yes, I remember that very well because I never could make it work without any crash, so I abandoned it quite soon. 8)

bogs
Posts: 2190
Joined: Sat Feb 25, 2017 10:45 pm

Re: Fast 2D graphics for games and simulation

Post by bogs » Thu Sep 13, 2018 2:31 pm

ClipArtGuy wrote:
Thu Sep 13, 2018 12:37 am
bogs wrote:
Tue Aug 07, 2018 6:53 pm
Moving 5 small circles is possible, but even with lockScreen, lockMoves, etc that is really pushing the limits.
Check out this game, it seems to work fairly well moving more than 5 things around at time.
Heh, I did check out that stack. I counted about 5 to 7 things moving on screen at any given time. I then looked at the code, and there could be up to 15 things moving under some circumstances, but they are moving between 2 points in a straight line.

Try taking one of the line coordinates and changing them to something like this path, and the speed/smoothness of the move for that object goes away -

Code: Select all

82,104
82,101
81,101
68,83
68,83
68,81
68,81
67,81
67,81
67,78
67,78
67,78
67,78
67,77
67,77
67,77
67,75
66,75
66,75
66,73
66,73
66,73
66,71
65,71
65,68
65,68
65,68
65,66
65,66
65,64
65,64
65,62
65,62
65,62
65,61
65,61
65,61
65,59
65,59
65,56
65,56
65,54
65,54
65,54
65,52
65,52
65,50
65,50
65,50
65,48
65,48
65,46
65,46
65,46
65,44
65,44
65,44
65,42
65,42
65,42
65,42
65,40
65,40
65,40
65,38
65,38
65,38
65,36
65,36
65,36
65,36
65,34
65,34
66,34
66,32
66,32
66,32
66,30
66,30
67,30
67,30
67,28
67,28
67,26
68,26
68,26
68,23
68,23
68,23
68,21
69,21
69,21
69,19
69,19
69,19
69,19
69,18
70,18
70,18
70,18
70,18
70,18
71,16
71,16
71,14
71,14
72,14
72,14
72,11
72,11
72,11
72,11
73,9
73,9
73,9
73,7
73,7
73,7
73,5
74,5
74,5
74,3
74,3
74,3
75,2
75,2
75,2
75,-1
75,-1
76,-1
76,-1
76,-1
76,-1
76,-3
76,-3
77,-5
77,-5
77,-5
77,-7
77,-7
78,-7
78,-7
78,-9
78,-9
78,-9
78,-11
78,-11
78,-11
79,-13
79,-13
79,-13
79,-13
79,-15
80,-15
80,-15
80,-17
80,-17
80,-17
81,-19
81,-19
81,-19
81,-19
81,-21
81,-21
82,-24
82,-24
82,-24
82,-24
82,-25
82,-25
83,-25
83,-27
83,-27
84,-29
84,-29
84,-29
84,-31
84,-31
84,-31
85,-34
85,-34
85,-34
85,-36
85,-36
85,-36
85,-38
86,-38
86,-38
86,-40
86,-40
86,-40
86,-41
86,-41
87,-41
87,-43
87,-43
87,-46
87,-46
87,-48
87,-48
87,-48
87,-50
87,-50
87,-50
87,-52
87,-52
87,-54
87,-54
87,-56
87,-56
87,-56
87,-58
87,-58
87,-60
87,-60
87,-60
87,-62
87,-62
87,-64
86,-64
86,-66
86,-66
86,-66
86,-68
86,-68
86,-68
86,-70
85,-70
85,-72
85,-72
85,-72
85,-74
85,-74
85,-74
85,-76
84,-76
84,-76
84,-79
84,-79
84,-79
84,-79
84,-79
84,-81
83,-81
83,-81
83,-83
82,-84
82,-84
82,-84
82,-84
82,-86
81,-86
81,-88
81,-88
81,-91
80,-91
80,-93
80,-93
79,-93
79,-93
79,-95
79,-95
79,-97
78,-97
78,-97
78,-97
78,-99
78,-99
78,-99
77,-99
77,-100
77,-100
77,-100
Having said that, let me also point out my answer was to this -
Arvin wrote:
Tue Aug 07, 2018 4:53 pm
I require up to a thousand or more of tiny sprites moving around smoothly
Now, if you know someone that has a stack moving 1000 objects around smoothly (hopefully along a path that consists of more than 2 points!), that would indeed be something to see, and I'd be happy to correct the opinion I put up in this thread, but I just don't see it happening. Bonus points if they are moving along randomly generated points of a path :mrgreen:

*Edit - by the way, love your home page :twisted:
You have walked into the slavering fangs of a lurking grue!
Image

ClipArtGuy
Posts: 184
Joined: Wed Aug 19, 2015 4:29 pm

Re: Fast 2D graphics for games and simulation

Post by ClipArtGuy » Thu Sep 13, 2018 4:51 pm

bogs wrote:
Thu Sep 13, 2018 2:31 pm


Try taking one of the line coordinates and changing them to something like this path, and the speed/smoothness of the move for that object goes away -
I took a look through the script, and changed a few of the line paths of the enemies in that stack to be more complex than just a straight line, and the performance was significantly degraded. I can only imagine that trying to move thousands of objects would be near impossible even on straight paths. I was just reminded of that stack by your post, since it is technically moving more than 5 objects smoothly, but when given a more complex path, the smoothness and speed pretty much disappear immediately.

Maybe (probably?)something like Love2D would be better suited for this type of thing?

https://love2d.org/

EDIT: Perhaps whenever LC gets around to releasing the long awaited 2D physics engine in LC, it will make things smoother. It seems like we *may* get something in 9.1, but as 2D physics was a fully funded stretch goal of the original 2013 kickstarter, and has yet to materialize, I wouldn't hold my breath...
physics.jpg

bogs
Posts: 2190
Joined: Sat Feb 25, 2017 10:45 pm

Re: Fast 2D graphics for games and simulation

Post by bogs » Thu Sep 13, 2018 5:57 pm

ClipArtGuy wrote:
Thu Sep 13, 2018 4:51 pm
... the performance was significantly degraded
Even as the demo stands, interrupting those loops (for instance, initiating quitting) takes a noticeable amount of time. I really don't want to sound like I'm knocking someones work, the demo is well put together for what it is, but being realistic I sure wouldn't want to try writing something extremely complex to compare to other languages made for this kind of thing.

Love2d is interesting, I think Scott Rosi pointed out Construct 2. I pretty much use Blender for stuff like that myself, and there are a few others that come to mind that work specifically towards that goal of smooth animation with a large number of objects.

Lc's physics engine should be interesting to test out when it shows up, so possibly in the future my opinion will become as obsolete as I am on this topic :P
Image

Post Reply

Return to “Creating Games”