Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / What's the fastest way to change individual pixels in a bitmap then use it as a texture on a landscape matrix??

Author
Message
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 4th Apr 2014 21:50
Hi,

I've resurrected my Zarch/Virus code in DBPro and have hit a bit of a stumbling block in terms of speed.

I need to dynamically update my landscape to reflect the spread of virus and also reflect this visually on the map.

I have the basic landscape generation code using a matrix which wraps round, works well and is fast:

https://www.youtube.com/watch?v=uIN-6uErBs8

The skin of my landcape matrix uses the same bitmap as the map but I need both to update dynamically in game.

Refreshing each of them in the main loop causes a major slow down as I'm using a for/next loop for x and z values then applying them to the matrix and map (must be a faster way).

I need a solution which allows me to alter individual pixels in the map bitmap which I can then paste onto the matrix in each loop.

Is there a way of doing this? I'd be grateful for any help.

[img]http://forum.thegamecreators.com/?m=forum_view&t=181020&b=5
Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 4th Apr 2014 22:42
You could use 3D models of a virus like grass on the landscape, and paste sprites on the map texture. That would be quite fast.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Apr 2014 00:00 Edited at: 5th Apr 2014 00:02
I think the fastest method would be to use ImageKit2, draw directly to the image that is textured onto the terrain.

There's also memblock images, but I'm sure ImageKit is faster as it avoids the memblock to image conversion. The downside is that it can be slower to check data than a memblock, so it might be wise to also store the pixel data in an array for fast checking.

I am the one who knocks...
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 5th Apr 2014 02:02
Thanks Barry,
The virus spreads to cover the whole of the non-water areas of the map which would need a lot of grass objects. I think this would quickly clog up. Worth a go on smaller levels tho.

Van B,
Just downloaded and installed imagekit2 and the IK Dot command is exactly what I need. Very easy to use to!

For each matrix co-ordinate I'm already storing the x,z and RGB values separately so pixel data changes are easy enough to add to match the infected point on the map. Need to record these anyway to total up %age of infection spread at the end of each level.

The IK flip image vertically command also looks very useful instead of converting to sprites to flip!

[img]http://forum.thegamecreators.com/?m=forum_view&t=181020&b=5

Login to post a reply

Server time is: 2025-05-14 00:15:42
Your offset time is: 2025-05-14 00:15:42