Developing RPG (Tile-based graphics with transparency)

Hannes Hirzel hirzel at spw.unizh.ch
Sat Jul 28 20:27:52 UTC 2001


Frantisek

Do you mean something like the following? 

"-------------------------------------------"
"Build original form (as example)"
"ABCDE
 FGHIJ"
"-------------------------------------------"

Display newDepth: 8.
g := ColorForm extent: 50 @ 20 depth: 8.

f := ColorForm extent: 10 @ 10 depth: 8.
f fill: f boundingBox fillColor: Color blue.
f displayOn: g at: 0 @ 0.
f fill: f boundingBox fillColor: Color red.
f displayOn: g at: 10 @ 0.
f fill: f boundingBox fillColor: Color yellow.
f displayOn: g at: 20 @ 0.
f fill: f boundingBox fillColor: Color brown.
f displayOn: g at: 30 @ 0.
f fill: f boundingBox fillColor: Color orange.
f displayOn: g at: 40 @ 0.
f fill: f boundingBox fillColor: Color green.
f displayOn: g at: 0 @ 10.
f fill: f boundingBox fillColor: Color lightBlue.
f displayOn: g at: 10 @ 10.
f fill: f boundingBox fillColor: Color black.
f displayOn: g at: 20 @ 10.
f fill: f boundingBox fillColor: Color white.
f displayOn: g at: 30 @ 10.
f fill: f boundingBox fillColor: Color cyan.
f displayOn: g at: 40 @ 10.

g displayAt: 100 @ 100.
g displayAt: 200 @ 200.

g writeBMPfileNamed: 'tiles.BMP'.



"----------------------------------"
"read form from file"
"----------------------------------"

g1 _ Form fromFileNamed: 'tiles.BMP'.


"-----------------------------------------------------"
"extract tiles"
"-----------------------------------------------------"

a _ g1 copy: (Rectangle origin: 0 at 0 extent: 10 @ 10).
b _ g1 copy: (Rectangle origin: 10 at 0 extent: 10 @ 10).
c _ g1 copy: (Rectangle origin: 20 at 0 extent: 10 @ 10).



"-----------------------------------------------------"
"Build result form by assembling the tiles"
"-----------------------------------------------------"

m _ ColorForm extent: 100 at 50 depth: 8.
0 to: 9 do: [ :i | a displayOn: m at: (10 * i) @ 0].
a displayOn: m at: 0 @ 10.
1 to: 8 do: [ :i | b displayOn: m at: (10 * i) @ 10].
a displayOn: m at: 90 @ 10.
a displayOn: m at: 0 @ 20.
b displayOn: m at: 10 @ 20.
2 to: 7 do: [ :i | c displayOn: m at: (10 * i) @ 20].
b displayOn: m at: 80 @ 20.
a displayOn: m at: 90 @ 20.
a displayOn: m at: 0 @ 30.
1 to: 9 do: [ :i | b displayOn: m at: (10 * i) @ 30].
a displayOn: m at: 90 @ 30.
0 to: 9 do: [ :i | a displayOn: m at: (10 * i) @ 40].
m displayAt: 200 @ 200.


"-----------------------------------------------------"
"Use the result form in an ImageMorph"
"-----------------------------------------------------"

(ImageMorph new image: m) openInWorld.



Actually I don't know how to read and write PNG files.
I would be interested to have an example.


Cheers

Hannes Hirzel





On Sat, 28 Jul 2001, Alan Kay wrote:

> Okay, take a look at the various Form classes and you should see how 
> to copy the contents of one Form into another.
> 
> I'd also look to see how Morphic uses Forms (for example in class 
> ImageMorph or class SketchMorph) for automatic display of your 
> results.
> 
> You can also completely bypass both Morphic and MVC and write your 
> own display routines from scratch ....
> 
> Cheers,
> 
> Alan
> 
> -------
> 
> 
> At 5:33 PM +0200 7/28/01, Frantisek Fuka wrote:
> >Alan Kay wrote:
> >
> >>I meant "what else are you trying to do?".  Many easy things can be 
> >>done in the children's authoring environment, but not all 
> >>escalations with work.
> >>
> >>If you bring in a picture, get its "halo of handles" by cmd-click 
> >>(alt-click on a PC) you will get its "viewer". If you move your 
> >>picture around with the mouse you will see the x and y properties 
> >>changing in the viewer. It is easy to make scripts that manipulate 
> >>these properties by dragging out tiles from the viewer and dropping 
> >>them on the desktop
> >
> >
> >I know what you are talking about but I don't know what this has to 
> >do with what I'm trying to achieve. Once more. Let's say I have 
> >tiles.png graphic file which is 20 pixels high and 50 pixels wide. 
> >It consists of 10 "tiles" images (A-J) with dimensions of 10x10 
> >pixels like this:
> >
> >ABCDE
> >FGHIJ
> >
> >Now, I want to import this file into Squeak and use these tiles to 
> >construct totally new image, for example this one, which will have 
> >dimensions of 50 (height) x 100 (width) pixels.
> >
> >AAAAAAAAAA
> >ABBBBBBBBA
> >ABCCCCCCBA
> >ABBBBBBBBA
> >AAAAAAAAAA
> >
> >So, I only need to 1) create some sort of empty "canvas"; 2) BitBlt 
> >(or something like that) tiles from tiles.png to this canvas. The 
> >result should be a single bitmap (Form?), not a collection of small 
> >morphs!
> >
> >--
> >                                          Frantisek Fuka
> >(yes, that IS my real name)
> >(and it's pronounced "Fran-tjee-shek Foo-kah")
> >----------------------------------------------------
> >My E-mail:   fuxoft at terminal.cz
> >My Homepage: http://www.fuxoft.cz
> >My ICQ:      2745855
> 
> 
> -- 
> 
> 
> 





More information about the Squeak-dev mailing list