Learning some new stuff in C++
New bin with palette punch
sky.bin (61.8 KB)
Whoa this looks great so far! Love the explosions. Reminds me a bit of the one tic-80 game you were working on like a year ago the way the background moves.
Also, I think your fps counter might be inaccurate. On hardware it seems to run faster than it reads. Keep it up
Nice use of colour.
The explosions remind me of The Minish Cap.
(Would be nice to see the source too.)
Beautiful!Cant wait to play it!
Awesome game.
Already a year, how the time flyā¦
Do you have some code to share on how measure FPS? Here mine in the update loop
Pokitto::Core g;
Pokitto::Display d;
//
d.setCursor(0,0);
d.print("FPS:");
d.print(1000/(g.getTime()-t));
t = g.getTime();
Iāll merge with latest Pokitto library and share as soon as it will be somehow stable. Itās mostly an experiment with basic c++ features, so nothing to learn from it.
Thanks both @Matej and @pjurkovi for the kindly words. I hope to add some basic game play to make it more enjoyable.
For FPS, itās best to simply increment a counter 1 per frame, and when 1 second has passed, copy this counter to your display variable then reset the counter to 0.
e.g.
currentFrameCount++;
if (g.getTime() - t > 1000)
{
t = g.getTime();
lastSecondFrameCount = currentFrameCount;
currentFrameCount = 0;
}
d.print("FPS: ");
d.print(lastFPSCount);
Also, this code could be adapted to stabilize time by skipping drawing.
There doesnāt seem to be a universal way of calculating FPS.
Thereās a whole page full of methods here on SO:
Seems people do like to use some kind of weighted average algorithm though.
I think ideally youād want to be caching the times to an array (or better yet, a circular buffer/fixed-size queue) and then summing them up until youāve got ~1 secondās worth (Iād say take whichever is closest to a second, even if that means using less data) and then dividing that.
I donāt know if any of the āweighted averageā stuff helps or not, Iām not a particularly good mathematician (though I try).
Iāve just been defining āPROJ_USE_FPS_COUNTERā and using that. Seems very accurate but takes some proformance hit.
currentFrameCount++;
if (g.getTime() - t > 1000)
{
t = g.getTime();
lastFPSCount= currentFrameCount; //<< small typo
currentFrameCount = 0;
}
d.print("FPS: ");
d.print(lastFPSCount);
Give me more or less same result on hardware (more smoothed obviously)
How big perf hit you have noticed? That should be quite fast to draw.
I canāt find that directive. Has it just been added recently?
Found it:
Actually,that is a bit old too. In the latest Github it is like this:
// FPS counter
#ifdef PROJ_USE_FPS_COUNTER
const uint32_t fpsInterval_ms = 1000*3;
fps_frameCount++;
if (now > fps_refreshtime) {
fps_counter = (1000*fps_frameCount) / (now - fps_refreshtime + fpsInterval_ms);
fps_refreshtime = now + fpsInterval_ms;
fps_frameCount = 0;
}
#endif
It is also automatically drawn directly on the screen (in Display::update()), not to the console window any more, so it works on hw too.
Iāve just point to GitHub repo here https://github.com/pokitto/PokittoSim
in Master branch.
Is there any other repo?
That is the old one and should not be used any more. Here is the official repo. It is for both the simulator and the HW builds. Or you can use mBed env for the HW builds also.
Iāve just update the bin with a modified palette. Now is more similar to my monitor output. I was enough to add some more brightness and contrast to the original palette. I modify on the fly img2pok to allow some tests.
The result is way better then before and more similar to initial gif posted
sky.bin (61.8 KB)
Does anybody study the best way to match monitor and lcd colors? @jonne ?
No. Only thing Iāve noticed you need much stronger colors on the lcd. For example, if you have a medium grey and medium brown they are hard to distinguish.
In the old days TV / CRT monitor games were often a sort of ācolor rampā of greys, blues or similar + a few contrast colors (strong violets, pink, yellow). Think Xenon Megablast and Amiga Bitmap Brothers games.
Same ramp + opposite color high visibility details strategy works well on the lcd.
I havenāt, but if I had to guess Iād assume that the answer lies in gamma correction, or some variance of gamma correction.
The explanation here is quite decent.
https://www.cambridgeincolour.com/tutorials/gamma-correction.htm