Using love for a battle demonstrator

General discussion about LÖVE, Lua, game development, puns, and unicorns.
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Using love for a battle demonstrator

Post 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
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Using love for a battle demonstrator

Post 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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Using love for a battle demonstrator

Post 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
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Using love for a battle demonstrator

Post 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
Attachments
2021-04-19T17_17_24-Untitled.png
2021-04-19T17_17_24-Untitled.png (13.7 KiB) Viewed 5966 times
2021-04-19T17_17_27-Untitled.png
2021-04-19T17_17_27-Untitled.png (17.6 KiB) Viewed 5966 times
bezier-05.love
bezier curve with zoom-to-mouse lib
(1.31 KiB) Downloaded 194 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Using love for a battle demonstrator

Post by darkfrei »

Another bezier-clicker with zoom-to-mouse:
Attachments
2021-04-19T17_57_48-Untitled.png
2021-04-19T17_57_48-Untitled.png (48.52 KiB) Viewed 5958 times
2021-04-19T18_02_05-Untitled.png
2021-04-19T18_02_05-Untitled.png (24.73 KiB) Viewed 5958 times
bezier-06.love
(1.46 KiB) Downloaded 198 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Using love for a battle demonstrator

Post 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
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Using love for a battle demonstrator

Post 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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Using love for a battle demonstrator

Post 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.
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Using love for a battle demonstrator

Post 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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Using love for a battle demonstrator

Post 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
Last edited by deb75 on Wed May 05, 2021 7:37 am, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests