Hextrategy イベントウインドウを作る


2019年 10月 11日
 
 
SAVE、LOADの実装に伴い、ここで初めてイベントウインドウを作る事にした。

 適当にイベントウインドウと呼んだが、下のようなものの事。


 
 

 まずグラフィックを用意する。

 ブロックの大きさは 16ドット、枠の部分と網の部分に分かれる。

 ソースは以下のようになる。

; ---------- イベントウインドウ ----------

#include "hsp3dish.as"

gosub *main : end


#module
#deffunc evw int f,int sx,int sy,int ox,int oy ;(イベントウインドウ、
; sx=描き始め座標x、sy=描き始め座標y、
; ox=ブロック大きさx、oy=ブロック大きさy)

	bo=16		; 1ブロックの大きさ

	switch f
	 case 0 ; 網
	  gmode 3,,,160 ; 透明表示
	  repeat oy : cnt2=cnt
	   repeat ox
	    x=sx+(cnt*bo) : y=sy+(cnt2*bo) ; 描画座標
	     pos x,y

	    if cnt=0 and cnt2=0		: celput evww@,8	: continue	; 左上
	    if cnt=ox-1 and cnt2=0	: celput evww@,9	: continue	; 右上
	    if cnt=0 and cnt2=oy-1	: celput evww@,12	: continue	; 左下
	    if cnt=ox-1 and cnt2=oy-1	: celput evww@,13	: continue	; 右下

	    celput evww@,10 ; それ以外
	   loop
	  loop
	 swbreak

	 case 1 ; 枠
	  x1=sx : x2=sx+((ox-1)*bo)
	  y1=sy : y2=sy+((oy-1)*bo)

	  gmode 2 ; 通常表示

; 四隅
	  pos x1,y1 : celput evww@,0	; 左上
	  pos x2,y1 : celput evww@,1	; 右上
	  pos x1,y2 : celput evww@,4	; 左下
	  pos x2,y2 : celput evww@,5	; 右下

; xライン
	  nx=ox-2
	  repeat nx
	   x=sx+bo+(cnt*bo)
	   pos x,y1 : celput evww@,2 ; 上ライン
	   pos x,y2 : celput evww@,6 ; 下ライン
	  loop

; yライン
	  ny=oy-2
	  repeat ny
	   y=sy+bo+(cnt*bo)
	   pos x1,y : celput evww@,7 ; 上ライン
	   pos x2,y : celput evww@,3 ; 下ライン
	  loop
	 swbreak
	swend

	return
#global


*main

	evww=1 ; イベントウインドウ
	 celload "../data_file2/ev_wk1.png",evww
	  celdiv evww,16,16


	redraw 0
	 color 1,1,1 : boxf : color 255,255,255

	 evw 0,100,100,20,10	; 網表示
	  pos 130,130 : mes "イベントウインドウ"
	 evw 1,100,100,20,10	; 枠表示
	redraw 1

	stop

 
 
 evw 0,100,100,20,10

 一つ目は、0=網、1=枠になる

 2つ目、3つ目は x,yの描き始め座標。

 4つ目、5つ目は、x,yのブロックの大きさになる。
 
 
 網の部分は、gmode 3,,,160となっているので、背景を透過する。
 
 
 他に特に説明する事はないと思うし、そんなに難しくないと思うので説明は以上。

 コマンドとかセリフとか選択とか、用途は様々。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です