Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Counter measures

 [1/11] from: al::bri::xtra::co::nz at: 5-Sep-2002 22:26


The drag and drop how-to at: http://www.rebol.com/how-to/feel.html might be helpful? I hope that helps! Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [2/11] from: g:santilli:tiscalinet:it at: 5-Sep-2002 12:44


Hi SunandaDH, On Thursday, September 5, 2002, 10:42:14 AM, you wrote: Sac> But I'm stuck at drawing a *circular* counter that can be dragged and dropped Sac> anywhere on the board: I'm not sure if I understand what you want... but can't you draw your circles on a transparent box that you can then move around as you wish? Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [3/11] from: carl:cybercraft at: 5-Sep-2002 23:08


On 05-Sep-02, [SunandaDH--aol--com] wrote:
> I'm trying to create a little board game, mainly as a way of > improving my VID/View skills.
<<quoted lines omitted: 36>>
> die red > ]
Try this... rebol [] ; This function just makes an image from a layout... make-die: func [color [tuple!] /local image][ layout [ image: box 30x30 effect [draw [ pen none fill-pen color none circle 14x14 15 ]] ] to-image image ] Board-elements: Stylize [ black-square: box 100.100.100 50x50 white-square: box white 50x50 ; 'die is now an image - note the 'key effect used ; to make the black in the image transparent. die: image make-die red effect [key 0.0.0] ] unview/all view layout [ styles board-elements space 0x0 across black-square white-square black-square return white-square black-square white-square return black-square white-square black-square return ; The 'feels here are just a copy of the drag & drop ; example from the 'feel how-to example on the REBOL ; site. Your dice can now be picked up and moved... d1: die feel [engage: func [face action event] [ if action = 'down [start: event/offset] if find [over away] action [ face/offset: face/offset + event/offset - start show face ] ]] d2: die feel [engage: func [face action event] [ if action = 'down [start: event/offset] if find [over away] action [ face/offset: face/offset + event/offset - start show face ] ]] ; Set original colors... do [ d1/image: make-die red d2/image: make-die blue ] ; Button for user-defined color. (; button "Change" [ d1/image: make-die random 255.255.255 show d1 ] ] -- Carl Read

 [4/11] from: carl:cybercraft at: 6-Sep-2002 1:17


Replying to my own post... On 05-Sep-02, Carl Read wrote:
> Try this... > rebol []
<<quoted lines omitted: 16>>
> die: image make-die red effect [key 0.0.0] > ]
[snip] That could be simplified by using an oval in a box, thus not requiring you to use an image. ie, the function could be tossed. So, 'die could be... die: box 30x30 effect [key 0.0.0 oval] and then you'd only need to change the dice' colors instead of creating a new image each time. That said, prettier dice could be created by using draw... -- Carl Read

 [5/11] from: anton:lexicon at: 5-Sep-2002 23:15


Here's another way that works on last full version REBOL/View 1.2.1.3.1 21-Jun-2001: Drag is not implemented, but you can click. view center-face layout [ box red at 40x40 box 50x50 white effect [merge oval key 0.0.0] feel [ engage: func [face action event][ if action = 'down [ face/offset: face/offset + 2x2 show face ] ] ] ] I didn't quickly figure out how to do this in latest betas. Effects pipeline is changing. Anton.

 [6/11] from: g:santilli:tiscalinet:it at: 5-Sep-2002 21:42


Hi Sunanda, On Thursday, September 5, 2002, 8:40:34 PM, you wrote: Sac> I'd like the item I'm dragging to be at the top. Do I have to re-order the Sac> faces in the layout and then show the whole thing? Or is there a cleverer way You need to swap the two faces in the pane block. The faces on a higher position are shown on top of those placed "before" them. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [7/11] from: carl:cybercraft at: 6-Sep-2002 10:14


On 06-Sep-02, [SunandaDH--aol--com] wrote:
> Thanks to (in order of receipt of postings), Andrew, Gabriele, Carl > and Anton for the extremely helpful responses. > One quick other question. In Carl's code (repeated below for easy of > reference
And complete even unto the typed-in-the-wrong window "unview/all". (:
>), the initially blue die is always on top of the initially > red one. I'd like to change that.
<<quoted lines omitted: 3>>
> Thanks, > Sunanda.
Gabriele's {You need to swap the two faces in the pane block. The faces on a higher position are shown on top of those placed "before" them.} is probably the way to do this, but I for one would like to see an example - as my attempt at doing it doesn't work. (: Carl.
> ;; Carl's code: > ; This function just makes an image from a layout...
<<quoted lines omitted: 60>>
> ] > ]
-- Carl Read

 [8/11] from: g:santilli:tiscalinet:it at: 6-Sep-2002 1:42


Hi Carl, On Friday, September 6, 2002, 12:14:50 AM, you wrote: CR> them.} is probably the way to do this, but I for one would like to CR> see an example - as my attempt at doing it doesn't work. (: swap: func [series] [reverse/part series 2 series] win: layout [ box 50x50 green at 45x45 box 50x50 red button "swap" [swap win/pane show win] ] view win Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [9/11] from: anton::lexicon::net at: 6-Sep-2002 15:14

Re: Counter measures - face depth arrangement


View draws each face in the order it is kept in the 'pane facet. Given the following face definition (yes, layout returns a face): lay-face: layout [box white at 50x50 box red] (Close the window now.) Examining the 'pane facet: length? lay-face/pane ;== 2 There are two sub-faces. Those are the two boxes. lay-face/pane/2/color ;== 255.0.0 ; (red) Let's see it: view lay-face To make the red box appear under the white box, you should just swap their positions in the pane. In this simple case we can just use reverse: reverse lay-face/pane view lay-face Anton.

 [10/11] from: carl:cybercraft at: 6-Sep-2002 18:44

Re: Counter measures


On 06-Sep-02, Gabriele Santilli wrote:
> Hi Carl, > On Friday, September 6, 2002, 12:14:50 AM, you wrote:
<<quoted lines omitted: 7>>
> ] > view win
Thanks Gabriele. I'd got stumped with how to swap a value in a series without removing and reinserting it, thus giving it a new reference. I'd forgotten about 'reverse. For Sunanda, here's the above method in action, just in case you're not familar with a layout's pane block. (It contains all the styles (or panes, if you will) in a layout.) I moved the dice to the end of the layout, as then they'll always be in front of anything else in the layout and swapping them becomes simple as you just need to swap the last two panes in the block. And your board's layout is now called 'board... rebol [] ; This function just makes an image from a layout... make-die: func [color [tuple!] /local image][ layout [ image: box 30x30 effect [draw [ pen none fill-pen color none circle 14x14 15 ]] ] to-image image ] Board-elements: Stylize [ black-square: box 100.100.100 50x50 white-square: box white 50x50 ; 'die is now an image - note the 'key effect used ; to make the black in the image transparent. die: box 30x30 effect [key 0.0.0 oval] ] swap: func [face][ if face/color <> get in last board/pane 'color [ reverse/part back back tail board/pane 2 show [d1 d2] ] ] view board: layout [ styles board-elements space 0x0 across black-square white-square black-square return white-square black-square white-square return black-square white-square black-square return ; User-defined color. (; button "change" [ d1/color: random 255.255.255 show d1 ] ; The 'feels here are just a copy of the drag & drop ; example from the 'feel how-to example on the REBOL ; site. d1: die feel [engage: func [face action event] [ if action = 'down [swap :d1 start: event/offset] if find [over away] action [ face/offset: face/offset + event/offset - start show face ] ]] d2: die feel [engage: func [face action event] [ if action = 'down [swap :d2 start: event/offset] if find [over away] action [ face/offset: face/offset + event/offset - start show face ] ]] ; Set original colors... do [ d1/color: red d2/color: blue ] ] -- Carl Read

 [11/11] from: gscottjones:mchsi at: 6-Sep-2002 4:25


From: Sunanda
<snip> > I need to take an arbitrary screen element and pop it to the top. I think > this revised code does that. The change is mainly replacing Gabriele's
Swap
> with 'move-to-end, and tweaking Carl's code to use this new function.
This is cool! While in theory I had previously recognized how this effect might be done, I had never realized how *easily* it could be done. And just a final bit of *gratuitous* refactoring: - moved feel up to stylize definition - defined die color at die instantiation (that's why I said it was gratuitous :-) Cool! --Scott Jones rebol [] unview/all ; This function just makes an image from a layout... make-die: func [color [tuple!] /local image][ layout [ image: box 30x30 effect [draw [ pen none fill-pen color none circle 14x14 15 ]] ] to-image image ] Board-elements: Stylize [ black-square: box 100.100.100 50x50 white-square: box white 50x50 ; 'die is now an image - note the 'key effect used ; to make the black in the image transparent. ; and ; The 'feel here are just a copy of the drag & drop ; example from the 'feel how-to example on the REBOL ; site. die: box 30x30 effect [key 0.0.0 oval] feel [engage: func [face action event] [ if action = 'down [move-to-end board/pane face start: event/offset] if find [over away] action [ face/offset: face/offset + event/offset - start show face ] ]] ] move-to-end: func [series item /local item-index item-value][ item-index: find series item item-value: first item-index remove item-index append series item-value show last series show item-value ] view board: layout [ styles board-elements space 0x0 across black-square white-square black-square return white-square black-square white-square return black-square white-square black-square return ; User-defined color. (; button "change" [ d1/color: random 255.255.255 move-to-end board/pane d1 ] d1: die red d2: die blue return d3: die green d4: die yellow ]

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted