A curious animated Fog of War problem - need help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

A curious animated Fog of War problem - need help

Post by Jack Dandy »

Hey there. I made a game with a 'fog of war' mechanic in it.


Image

There's a sample screenshot - I have black squares that are unexplored, semi-black squares which are currently unseen but were previously visited, and clear squares which are in my direct field of vision.

The Fog of War gets updated for every 'step' my character makes. (It's held into a grid).



Now, when I started it I just made the colors 'snap' into place. And it does so nice and instant!

Image

But then I tried to polish it a bit, by making the colors 'fade in' with tweening. (By using the Hump library's Timer:Tween module).

I gave each block a 'visibility' variable, and at the end of the function that generates the current fog of war status, I go over each square and tween it.

Problem is, it seems to have a weird 'delay'- the tweening starts after a short while, instead of instantly. All the tweens start and end at the same time, but with a delay.


Image


I tried testing some things:

Using Flux instead of hump's timer module: Didn't help

Seeing if it's due to running on all the squares: Doesn't seem to be it. It also happens when I only run it on the top-left 5x5 squares instead of the entire 16x16 screen.



I can't seem to figure out the problem. Anybody has a clue?
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: A curious animated Fog of War problem - need help

Post by pgimeno »

Can't tell for sure without any code to look at, but by looking at the gifs, it appears that you don't start (or update?!) the tween when the character starts to move, but when the character arrives, leaving very few frames (2 or 3) for the tween. Hard to say more without actual code.
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

Re: A curious animated Fog of War problem - need help

Post by Jack Dandy »

It only appears that way due to the gif's limited framerate. In the game, the changes seen in 1st gif take place as soon as the sprite starts moving.

The FoW is based solely the character's data in the matrix, using the ROTLOVE library's FOV module.

https://github.com/paulofmandown/rotLove

IE, every time the character takes a step, the data in the positional matrix changes - and the new FoW is calculated (up to this point, everything is done instantly, no delays there), but after I try to launch tweens to illustrate these changes there's the delay.

And the delay is what I'm trying to figure out.
Last edited by Jack Dandy on Fri May 24, 2019 12:56 pm, edited 2 times in total.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: A curious animated Fog of War problem - need help

Post by pgimeno »

Yes, it's clear in the first gif. However, in the second gif that's not the case. Nothing at all gets updated in the screen until the character stops moving, which makes me think that you're not updating the tween while the character displaces.

Again, it's not possible to offer more help than that without being able to look at the code.
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

Re: A curious animated Fog of War problem - need help

Post by Jack Dandy »

Goddamn, please disregard this thread - I'm a fool. Accidentally called the FoW generating function from the update() as well.
No wonder it lagged, being launched every millisecond. I'll be able to fix this.

Still thanks for the suggestions.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 71 guests