Page 1 of 2

Using love for a battle demonstrator

Posted: Sun Apr 18, 2021 1:51 pm
by deb75
Hello,

I have to build a demonstrator which is something very much like a 2d battle game consisting in two players,
one attacking with fighters, helicopters, missiles, and another defending its area with some radars and
missile launchers.

The purpose of the defender is to allocate its missiles to each targets it detects so as to neutralize completely
the attack.

I wonder if love2d could act as an interface for this demonstrator, that is to say show the fight run with
targets moving, missiles from launchers allocated to targets and destroying them. The object movements
and allocations are computed by another program so, instead of human interaction, the love2d game
would have to read events (target moving, destroyed, ...) from that other program.

Is it possible to make love2d update the graphic by reading periodically events issued by another program ?

Also, I am interested in love2d because of lua and the potential graphical possibilities.
- can I display some tooltips on mouse hovering/clicking on objects ? e.g. display position and speed of a target
- is it possible to use svg for objects ?
- is it possible to zoom in and out ?
- is it possible to change the background while zooming ? This is essential as the background would be a map
with less or more details depending on the zoom level
- is it possible to draw semi-transparent surfaces ? When hovering on a radar, I would like its range appear as
a semi-transparent surface.
- can I display a table in a graphical way ? as opposed to text only

Thanks in advance for your attention

Regards

deb75

Re: Using love for a battle demonstrator

Posted: Sun Apr 18, 2021 7:49 pm
by darkfrei
deb75 wrote: Sun Apr 18, 2021 1:51 pm
- is it possible to use svg for objects ?
I think almost all points: yes, but:
Not direct svg, but you can make own parser for it.

In this project I've used a map to make the svg, than I've saved it in absolute coordinates and saved as .lua table:

https://love2d.org/forums/viewtopic.php?f=14&t=89792
Here is also the zoom-to-mouse module.

Re: Using love for a battle demonstrator

Posted: Mon Apr 19, 2021 2:00 pm
by deb75
Thanks for your answeer.

I dug a little into love2d.

For tooltips, I could draw a semi-transparent rectangle with some text inside,
but maybe there already exists a library for tooltip, attached to objects ?

For zooming in/out, there is the "love.graphics.scale" function.

I also noticed the use of "canvas". Is it possible to overlay several canvas ? so that
I can draw targets on one canvas, missile launchers on another, radars on another, and so on ...

Is it possible to draw curves ? like cubic splines or polynomes ?

Regards

Re: Using love for a battle demonstrator

Posted: Mon Apr 19, 2021 2:40 pm
by darkfrei
deb75 wrote: Mon Apr 19, 2021 2:00 pm Thanks for your answeer.

I dug a little into love2d.

For tooltips, I could draw a semi-transparent rectangle with some text inside,
but maybe there already exists a library for tooltip, attached to objects ?

For zooming in/out, there is the "love.graphics.scale" function.

I also noticed the use of "canvas". Is it possible to overlay several canvas ? so that
I can draw targets on one canvas, missile launchers on another, radars on another, and so on ...

Is it possible to draw curves ? like cubic splines or polynomes ?

Regards
Yes, you can overlay canvases (I think, I have no experience).
https://love2d.org/wiki/Canvas

You can use bezier curves:
https://love2d.org/wiki/BezierCurve

Re: Using love for a battle demonstrator

Posted: Mon Apr 19, 2021 4:02 pm
by darkfrei
Another bezier-clicker with zoom-to-mouse:

Re: Using love for a battle demonstrator

Posted: Sun May 02, 2021 7:46 pm
by deb75
Thanks for your answers.

I have anohter question. The battle between fighters and missile launchers should take place on a map,
just like a zoomable google map.

I retrieved data from openstreetmap for some european country and generated with it thousand of tiles (png images)
for the domain and each zoom level. The highest zoom level is of the order of a medium size city.

I would like to be able to zoom in/out and the love2d game background be filled with the appropriate tiles.

I wonder if this can be achieved by assembling all tiles from a given zoom level, so as to get one big image of the country,
and use the function "love.graphics.newQuad" to select the appropriate part of the image corresponding to the love2d screen ?

Regards

Re: Using love for a battle demonstrator

Posted: Sun May 02, 2021 8:46 pm
by darkfrei
If they are really huge, on zoom level 5 you can load image for zoom level 4 and 6, not other.
By moving to the zoom level 4 you are need to unload zoom level 6 and load zoom level 3.

Re: Using love for a battle demonstrator

Posted: Sun May 02, 2021 9:32 pm
by deb75
darkfrei wrote: Sun May 02, 2021 8:46 pm If they are really huge, on zoom level 5 you can load image for zoom level 4 and 6, not other.
By moving to the zoom level 4 you are need to unload zoom level 6 and load zoom level 3.
Thanks for your answer, I do not understand exactly what you say.

Tile images are about 1K size, of course there are lots of them, especially for high zoom levels.
As an example, for zoom 10, it is about 34M.

Re: Using love for a battle demonstrator

Posted: Mon May 03, 2021 7:28 am
by darkfrei
deb75 wrote: Sun May 02, 2021 9:32 pm
darkfrei wrote: Sun May 02, 2021 8:46 pm If they are really huge, on zoom level 5 you can load image for zoom level 4 and 6, not other.
By moving to the zoom level 4 you are need to unload zoom level 6 and load zoom level 3.
Thanks for your answer, I do not understand exactly what you say.

Tile images are about 1K size, of course there are lots of them, especially for high zoom levels.
As an example, for zoom 10, it is about 34M.
It will be much easier to make small proof-of-concept program and attach it here.
An example with 2-3 zoom levels must be enough.

Re: Using love for a battle demonstrator

Posted: Mon May 03, 2021 8:10 am
by deb75
yes, you are right, I am ready to do it, now that I have all the tiles.

the zoom level 13 weights 1.2Go. Do you think love2d can load such a big image ? My laptop has 16Go of RAM.

EDIT :

I have just discovered this page : https://love2d.org/wiki/Tutorial:Effici ... %C3%A7ais)
which seems to be exactly what I am looking for. I will propose a Proof of Concept base on this.

Regards