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 Discussion / Putting a image memblock on a grid

Author
Message
Donald Smith
22
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 23rd Jan 2019 06:34 Edited at: 23rd Jan 2019 06:38
So, here's my issue, then a question.

I'm running DBC 1.12 Enhanced and I came across Wipes and memblocks for images (first time using these) which would handy in a game I'm making, but the question is if my game uses a 3 x 3 grid (think tic-tac-toe) or:

1 | 2 | 3
---|---|---
4 | 5 | 6
---|---|---
7 | 8 | 9

and if I choose 9, for example, how can I get the 9 memblock image, execute the downward wipe, execute the upward wipe then restore the 9 memblock image?

Thanks, dsmith
Donald Smith
22
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 25th Jan 2019 15:25
So, can the memblock idea work? If not, 1) what about using sprites and the wipes dll or 2) can a sprite be programmed to start at the top line by line to "disappear" ?

Thanks, dsmith
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Jan 2019 18:46
Hi,

not at a DBC computer right now, but i might have some time to take a look a little later
Enjoy your day.
Donald Smith
22
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 29th Jan 2019 00:15
Thanks Latch. By the way, the images are the exact size.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Jan 2019 05:19 Edited at: 29th Jan 2019 15:43
Hi Donald,

I couldn't find the wipe program, I'll have to dig around a little bit more on that. However, I can tell you the concept of how to do a wipe and supply you with some example code.

Basically, you page flip through different bitmaps. You might store a few different images on background bitmaps, and then swap in portions of those screens to the main viewable screen in locations that you choose.

In the example code, I create a colored grid on screen 0 (the main viewable screen). I copy that to bitmap 1 so I have a backup of it when I want to redraw the main screen in it's original state. next I create a background image on bitmap 2. I then slowly copy the pixels in the location of square 9 from bitmap 2 to bitmap 0. Once that's done, I copy bitmap 1 to bitmap 0 in the same location to restore square 9.

Then just for fun, I do a full wipe of bitmap 2 to 0 and then restore 0



could we achieve something similar with memblocks? Yes. It's a little bit more complicated. The concept is similar:

1. you need a memblock that would hold the original image
2. you need a memblock that holds the second image
3. it's helpful to have a third memblock where you can write stuff to combining the first two images

One method could go something like this:

first thing is to make a memblock from bitmap 0 (your main screen)

A. make a copy of memblock 1 into memblock 3
B. find the position in memblock 1 that you want to change
C. copy or write the data from memblock 2 to memblock 3 at the position in memblock 3 you determined from memblock 1
D. make a bitmap from memblock 3 to bitmap 0 (MAKE BITMAP FROM MEMBLOCK 0,3)



Enjoy your day.
Donald Smith
22
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 29th Jan 2019 22:28
Latch,
Attached is the WipeDemo files.

Thanks for your help, Donald

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Jan 2019 16:28 Edited at: 30th Jan 2019 16:34
Hi D.,

I looked at the wipe DBC code and also the Delphi code. I'm not familiar with Delphi but think I have a general enough knowledge of programming to kind of sort out what the code means. I could be wrong, but looking at the Delphi code, it looks like the operations are always on the full screen and a single step affects a NxN pixel block. There are main arrays that hold 768 positions (assumingly to allow a maximum screen resolution of 1024 x 768). I believe the block sizes are determined by the actual screen resolution and the blocks - the groups of pixels affected at once - are pulled based on the block position in the arrays. So for example, if array position 200 has a block value of 767 in it, it will affect the area of the screen somewhere in the lower right hand corner depending on the block pixel size. It seems that the transitions are hard coded to affect the entire screen. If you choose bumpup or spiral or whatever, it's going to affect the entire screen.

With all that being said, I don't think there is a way out of the box to affect just the lower number 9 square in your example with the wipe DLL. However, if I recall there was a program that came with the wipe demo that allows you to create a customized wipe. If so, you could probably create the effect you want. You could also alter the code at the end of the DBC example.



In theory, since the DLL uses pointers, you could create small offscreen bitmaps that are the size of the square you want to wipe. You would then perform the wipe on this screen and copy the bitmap into the location on your main screen.

This possibility seems kinda interesting, so when i get home, I might tinker a bit.
Enjoy your day.

Login to post a reply

Server time is: 2024-11-17 22:18:25
Your offset time is: 2024-11-17 22:18:25