Games [Project] Kingdom Crisis (KZ Engine)

wonder

Expert
Licensed User
Longtime User
I've started to experiment with some lighting effects... :)

Untitled.png

...or shall I say, "darkness" effects!
 

wonder

Expert
Licensed User
Longtime User
For now, using nothing more than some texture masking tricks...

B4X:
Batch.DrawTex2(textures(spotLightIndex), left  , top, spotLightSize              , spotLightSize            )     'Center
Batch.DrawTex2(textures( darknessIndex), 0     , 0  , left                       , top                      ) 'Top-Left
Batch.DrawTex2(textures( darknessIndex), right , 0  , Common.MAX_SCREEN_X - right, top                      ) 'Top-Right
Batch.DrawTex2(textures( darknessIndex), 0     , btm, left                       , Common.MAX_SCREEN_Y - btm) 'Btm-Left
Batch.DrawTex2(textures( darknessIndex), right , btm, Common.MAX_SCREEN_X - right, Common.MAX_SCREEN_Y - btm) 'Btm-Right
Batch.DrawTex2(textures( darknessIndex), 0     , top, left                       , spotLightSize            ) 'Ctr-Left
Batch.DrawTex2(textures( darknessIndex), right , top, Common.MAX_SCREEN_X - right, spotLightSize            ) 'Ctr-Right
Batch.DrawTex2(textures( darknessIndex), left  , 0  , spotLightSize              , top                      ) 'Ctr-Top
Batch.DrawTex2(textures( darknessIndex), left  , btm, spotLightSize              , Common.MAX_SCREEN_Y - btm) 'Ctr-Btm
This code is still very rudimentary, lacks optimization and might even be totally discarded.

Nonetheless, as for now, it does the trick... ;)
 

ilan

Expert
Licensed User
Longtime User
got it, thanx i will use it for 1 or 2 of my levels. :)

Screenshot_2016-11-13-22-35-27.png


BTW i do it with 1 line :p

Batch.DrawTex2(lightning,lightvec.x-vpW,lightvec.y-vpH,vpW*2,vpH*2)
the light follows the player position where ever it goes and always covers the whole screen.
result is great :)
 
Last edited:

ilan

Expert
Licensed User
Longtime User
Are you sure you won't get different results on different screen sizes?

i scale down my screen so it look on each device the same.
i use the same technique andymc used in his cloney bird example.

only the box2d world is define in meters but i tested my game on tablet 10" and i have the same results.
 
Last edited:

ilan

Expert
Licensed User
Longtime User
have you made any new progress with your game?
if so post some vid's, i like to watch them :)
 

wonder

Expert
Licensed User
Longtime User
@ilan

It might not look like much, but I'm now about to cast a small portion of the screen (160x90px) from Android (OpenGL buffer) to the PC, via UDP + Zip.

On the Android side, it takes 2.35 milliseconds to render the entire frame AND compress the given portion and send it via UDP.

So far, I'm getting real-time results (60fps on both), but my current canvas based B4J renderer will probably be too rudimentary and slow to render an entire frame (1280x720).

If I'm ever able to send such a huge amount of information 60 times per second (it must be possible, right?), I'll rewrite the PC receiver in C++ / OpenGL.

1f8fd5b313.png
 

ilan

Expert
Licensed User
Longtime User
are you sending the whole image? why?

what is the purpose of it? should it be a multiplayer game?
if yes i would send just the x/y coordinate of the player and all enemies and just what happen in the game from the sender and simulate everything on the receiver instead of send 60 screenshots per second
 

wonder

Expert
Licensed User
Longtime User
No, I want to have the option of screen-casting the game in real-time to a PC (Windows/Linux).
At the same time, the game would receive input (via UDP) from the PC (Keyboard / Gamepad).

Another implementation would be live-broadcasting (youtube, twitch, etc...). :)

Side-note: This is a great learning exercise, combining lower-level OpenGL with networking protocols! :D
 
  • Like
Reactions: eps

ilan

Expert
Licensed User
Longtime User
nice, but how are you sending it? is it over wifi? would you get the same result sending it over 3g (smartphone) to pc?
 

ilan

Expert
Licensed User
Longtime User
i am not an expert, but if i would want to send via wifi, 3g, bluetooth the same happening on my screen i would send just information's like coordinates and camera position,...

for example let say i want to make a pong game multiplayer over the net, what i would do is sending from 1 device to the second device every time when the player location change just the location of it and on the second device i would move the first player to that location... the same with the ball...

so this could be the same when you want to screen-casting, you run the same program on both device and always send the updated coordinates of the player to the second device and your program will move it ...

should be much less bytes to send.. :)
 

wonder

Expert
Licensed User
Longtime User
I would send screen coordinates if I had the game engine running on the PC, which I don't. So I'm sending "video", nVidia Geforce Now works this way.
It allows you to stream and play PC games on Android. I'm attempting the reverse, playing Android on the PC, without emulation.

The purpose of this experiment is to be able to play the game on a bigger screen, without the use of an HDMI cable, just simple a simple WiFi connection.

Like I stated above, I'm using the UDP protocol to send compressed data over the network.
What you see on screen is the emulator sending data to my PC, so in other words Android (VirtualBox) ----> Windows.

Tomorrow I'll be able to test real-device ---> PC on local WiFi.
 
Last edited:

sorex

Expert
Licensed User
Longtime User
try a standard run lenght encoding, it's way faster in packing and depacking than the zipping you use and you can create your own optimal format.

it would give nice results on that polygon based background you have there maybe best resulting per channel.
 
Last edited:

wonder

Expert
Licensed User
Longtime User
@sorex, thanks for the tip! I've managed to achieve stable results with UDP, but unfortunately I don't think B4J is fast enough to render an entire frame 30 times per second, despite my best efforts. I'll try to write an OpenGL C++ based solution, one of these days.

In other news, I have to say, I'm quite proud of my *new* in-game micro scripting system... ;)
I'll post a video soon! Stay tuned! :)
 
Last edited:

sorex

Expert
Licensed User
Longtime User
maybe openGL can help to use delta compression and return only the blocks that have changed.

then you only need to send over the changed blocks (64x64 or whatever size you want to use)

that should speed up things (unless the entire screen changes ofcourse)
 

wonder

Expert
Licensed User
Longtime User
I'll post a video soon! Stay tuned!
Would you guys like a quick demo, as always, or something different this time?

I was thinking about a little bit of live coding and gameplay with voice-over... :)
 

wonder

Expert
Licensed User
Longtime User
Version 0.0.50a is out!

I wanted to do a voice over, but I couldn't find my headset... so next time...

NEW:
- Screen shaking
- Messaging System / Micro-Scripting
- Internal Functions (MS)
- Triggers (MS)
- I/O Keys (MS)
 
Top