Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias luxwar {
- if ($window(@luxwar)) { window -a @luxwar }
- else {
- window -BCdp +t @luxwar 0 0 640 480
- ;dll $+(",$scriptdir,fullscreen.dll,") Fullscreen640x480 $window(@luxwar).hwnd
- %ticks = $ticks
- %luxwar.x = 150
- %luxwar.y = 150
- %luxwar.dir = 0
- .timerluxwar -h 1 0 drawluxwar
- }
- }
- alias -l drawluxwar {
- var %win @luxwar
- if ($window(%win)) {
- ;begin frame
- inc %fps
- if ($calc($ticks - %ticks) >= 1000) { %_fps = %fps | %fps = 0 | %ticks = $ticks }
- clear -n %win
- drawtext -nr %win 0 tahoma 11 10 10 FPS: %_fps
- drawtext -nr %win 0 tahoma 11 10 30 use as teclas W A S D para movimentar - Alt+Z para fechar
- drawdot -nr %win 1 3 %luxwar.x %luxwar.y
- var %dir $point_direction($mouse.x,$mouse.y,%luxwar.x,%luxwar.y)
- ;var %dir $point_direction(%luxwar.x,%luxwar.y,$mouse.x,$mouse.y)
- drawline -nr %win $rgb(222,2,2) 1 %luxwar.x %luxwar.y $calc(%luxwar.x + $lengthdir_x(10,%dir)) $calc(%luxwar.y + $lengthdir_y(10,%dir))
- drawtext_ext -nr %win 0 tahoma 11 10 60 200 20 angle: %dir - mouse: $mouse.x x $mouse.y - %luxwar.x x %luxwar.y
- drawtext_ext -nr %win 0 tahoma 11 10 130 200 20 distance: $point_distance($mouse.x,$mouse.y,%luxwar.x,%luxwar.y)
- drawrect -nrf %win 0 0 200 200 332 32, 400 200 32 332, 400 400 32 332, 0 330 700 32
- %luxwar.tirolen = 1
- var %stop 0
- while (%stop = 0) {
- ;.dll $+(",$scriptdir,WhileFix.dll") WhileFix .
- var %wf $calc(%luxwar.x + $lengthdir_x(%luxwar.tirolen,%dir))
- var %hf $calc(%luxwar.y + $lengthdir_y(%luxwar.tirolen,%dir))
- var %getdot $getdot(%win,%wf,%hf)
- ;echo -a > %getdot
- inc %luxwar.tirolen 31
- if (%getdot = $rgb(0,0,0)) || (%wf < 0) || (%wf > 640) || (%hf < 0) || (%hf > 480) {
- %luxwar.tirolen = 1
- %stop = 1
- ;drawline -nr %win $rgb(2,222,2) 2 %luxwar.x %luxwar.y %wf %hf
- }
- }
- drawline -nr %win $rgb(2,222,2) 2 $calc(%luxwar.x + $lengthdir_x(6,%dir)) $calc(%luxwar.y + $lengthdir_y(6,%dir)) %wf %hf
- /*
- %luxwar.tirolen = 4
- var %wf $calc(%luxwar.x + $lengthdir_x(%luxwar.tirolen,%dir))
- var %hf $calc(%luxwar.y + $lengthdir_y(%luxwar.tirolen,%dir))
- var %getdot $getdot(%win,%wf,%hf)
- var %collision $false
- ;while (%getdot != $rgb(0,0,0)) || (%wf > 0) || (%wf < 640) || (%hf > 0) || (%hf < 480) {
- while (%collision = $false) {
- .dll $+(",$scriptdir,WhileFix.dll") WhileFix .
- inc %luxwar.tirolen 1
- var %wf $calc(%luxwar.x + $lengthdir_x(%luxwar.tirolen,%dir))
- var %hf $calc(%luxwar.y + $lengthdir_y(%luxwar.tirolen,%dir))
- var %getdot $getdot(%win,%wf,%hf)
- ;echo -a > %getdot
- if (%getdot = $rgb(0,0,0)) { %collision = $true }
- if (%wf < 0) || (%wf > 640) || (%hf < 0) || (%hf > 480) { %collision = $true }
- drawline -nr %win $rgb(2,222,2) 2 %luxwar.x %luxwar.y %wf %hf
- }
- */
- ;drawline -nr %win 0 1 %luxwar.x %luxwar.y $calc(%luxwar.x + $lengthdir_x(10,%luxwar.dir)) $calc(%luxwar.y + $lengthdir_y(10,%luxwar.dir))
- ;drawline -nr %win 0 1 %luxwar.x %luxwar.y $calc(%luxwar.x + $lengthdir_x(5,$calc(%luxwar.dir +90))) $calc(%luxwar.y + $lengthdir_y(5,$calc(%luxwar.dir +90)))
- ;drawline -nr %win 0 1 %luxwar.x %luxwar.y $calc(%luxwar.x + $lengthdir_x(5,$calc(%luxwar.dir -90))) $calc(%luxwar.y + $lengthdir_y(5,$calc(%luxwar.dir -90)))
- ;if (%luxwar.speed > 0) { dec %luxwar.speed 0.01 }
- ;if (%luxwar.speed < 0) { %luxwar.speed = 0 }
- ;%luxwar.x = $calc(%luxwar.x + $lengthdir_x(%luxwar.speed,%luxwar.dir))
- ;%luxwar.y = $calc(%luxwar.y + $lengthdir_y(%luxwar.speed,%luxwar.dir))
- drawdot %win
- .timerluxwar -h 1 0 drawluxwar
- }
- }
- ;/drawtext_ext -c[hnrpbo] @ <color> [color] <fontname fontsize> <x y w h> <text>
- ;Desenha texto com multiplas linhas
- alias drawtext_ext {
- var %toks 10
- var %flags $1
- var %win $2
- var %cor $3
- if (c !isin $1) { %flags = -c $+ $remove(%flags,-) }
- if (b isin $1) {
- var %cor2 $4
- var %font $5
- var %fsize $6
- var %x $7
- var %y $8
- var %w $9
- var %h $10
- inc %toks
- }
- else {
- var %font $4
- var %fsize $5
- var %x $6
- var %y $7
- var %w $8
- var %h $9
- }
- var %text $gettok($1-, [ [ %toks ] $+ ] -,32)
- var %lines $wrap(%text,%font,%fsize,%w,0)
- var %now 1
- while (%now <= %lines) {
- drawtext %flags %win %cor %cor2 %font %fsize %x %y %w %h $wrap(%text,%font,%fsize,%w,%now)
- inc %y $calc($height(%text,%font,%fsize) +3)
- inc %now
- }
- }
- ;$point_distance(x1,y1,x2,y2)
- alias point_distance { return $calc((($4 - $2) ^ 2 + ($3 - $1) ^ 2) ^ (1/2)) }
- ;$point_direction(x1,y1,x2,y2)
- alias point_direction {
- if ($1 == $3) { return $iif($4 > $2,270,90) }
- return $calc($iif($atan($calc(($4 - $2)/($3 - $1))).deg < 0,$calc($v1 +180),$v1) + $iif($4 > $2 || ($4 == $2 && $3 > $1),180,0))
- }
- alias radtodeg { return $calc($1 * 180/ $pi ) }
- alias degtorad { return $calc($1 * $pi /180) }
- ;$lengthdir_x(len,dir)
- alias -l lengthdir_x { return $calc( $cos($2).deg * $1) }
- ;$lengthdir_y(len,dir)
- alias -l lengthdir_y { return $calc( $sin($2).deg * $1) }
- alias -l keypress {
- /*
- if ($1 == 37) {
- dec %luxwar.dir 3
- if (%luxwar.dir <= 0) { %luxwar.dir = $calc(360- %luxwar.dir) }
- }
- if ($1 == 38) {
- if (%luxwar.speed < 2) { inc %luxwar.speed 0.3 }
- }
- if ($1 == 39) {
- inc %luxwar.dir 3
- if (%luxwar.dir >= 360) { %luxwar.dir = $calc(%luxwar.dir -360) }
- }
- */
- ;%luxwar.lastx = %luxwar.x
- ;%luxwar.lasty = %luxwar.y
- var %gd.d $getdot(@luxwar,$calc(%luxwar.x +3),%luxwar.y)
- var %gd.e $getdot(@luxwar,$calc(%luxwar.x -3),%luxwar.y)
- var %gd.c $getdot(@luxwar,%luxwar.x,$calc(%luxwar.y -3))
- var %gd.b $getdot(@luxwar,%luxwar.x,$calc(%luxwar.y +3))
- if ($chr($1) = a) && (%gd.e != $rgb(0,0,0)) { dec %luxwar.x }
- if ($chr($1) = s) && (%gd.b != $rgb(0,0,0)) { inc %luxwar.y }
- if ($chr($1) = d) && (%gd.d != $rgb(0,0,0)) { inc %luxwar.x }
- if ($chr($1) = w) && (%gd.c != $rgb(0,0,0)) { dec %luxwar.y }
- ;if (%getdot = $rgb(0,0,0)) { %luxwar.x = %luxwar.lastx | %luxwar.y = %luxwar.lasty }
- }
- on *:keydown:@luxwar:*:{
- ;echo -a > $keyval
- .timerluxwarkeypress [ $+ [ $keyval ] ] 0 0 keypress $keyval
- }
- on *:keyup:@luxwar:*:{
- ;echo -a > $keyval
- .timerluxwarkeypress [ $+ [ $keyval ] ] off
- }
- on *:close:@luxwar:{
- ;dll $+(",$scriptdir,fullscreen.dll,") Reset
- }
- /*
- on *:ACTIVE:*:{
- ;echo Activated: $active De-Activated: $lactive
- if ($active = @luxwar) { dll $+(",$scriptdir,fullscreen.dll,") Fullscreen640x480 $window(@luxwar).hwnd }
- elseif ($lactive = @luxwar) { dll $+(",$scriptdir,fullscreen.dll,") Reset }
- }
- */
- ;-----------------------------------------------------------------------------------------
- alias rexgame {
- if ($window(@rex) || $hget(rex)) { return }
- window -pdkw0BC @REX -1 -1 640 480 | .titlebar @rex Game
- hmake rex 64
- hadd rex x 320
- hadd rex y 240
- hadd rex key 0
- hadd rex shoot 0
- hmake rexs 256
- drawrect -rnef @rex $rgb(64,128,64) 11 $calc($hget(rex,x) -5) $calc($hget(rex,y) -5) 11 11
- }
- on *:keydown:@rex:*:{
- if (!$keyrpt) {
- if ($keychar isin wasd) { hadd rex key $remove($hget(rex,key),$keychar) $+ $keychar }
- rex.atu.game 1
- .timerREX -mh 0 10 rex.atu.game
- }
- }
- on *:keyup:@rex:*:{ hadd rex key $remove($hget(rex,key),$keychar) }
- on *:close:@rex:{ hfree rex | hfree rexs | .timerREX off }
- menu @rex {
- mouse:{ rex.atu.game -1 }
- sclick:{ rex.add.shoot $mouse.x $mouse.y }
- dclick:{ rex.add.shoot $mouse.x $mouse.y }
- }
- alias -l rex.add.shoot {
- var %% = $point_direction($hget(rex,x),$hget(rex,y),$1,$2)
- hinc rex shoot
- hadd rexs $+(t,$hget(rex,shoot)) $hget(rex,x) $hget(rex,y) $calc(-5* $cos(%%).deg) $calc(-5* $sin(%%).deg)
- .timerREX -mh 0 10 rex.atu.game
- }
- alias -l rex.atu.game {
- if ($window(@rex) && $hget(rex)) {
- if ($1 < 0) { goto >> }
- if ($hget(rex,key) == 0 && $hget(rex,0).item == 3) { .timerREX off | return }
- var %key = $hget(rex,key)
- if (w isin %key) { hdec rex y }
- elseif (s isin %key) { hinc rex y }
- if (a isin %key) { hdec rex x }
- elseif (d isin %key) { hinc rex x }
- :>>
- drawrect -rfn @rex $rgb(255,255,255) 1 0 0 $window(@rex).w $window(@rex).h
- ;atualizar tiros
- var %x = 1,%< = $iif($1 < 0,1,0)
- while ($hget(rexs,%x).item) {
- tokenize 32 $v1 $hget(rexs,$v1)
- if ($2 < 0 || $3 < 0 || $2 > $window(@rex).w || $3 > $window(@rex).h) { hdel rexs $1 | goto < }
- if (%<) { goto > }
- tokenize 32 $1 $calc($2 + $4) $calc($3 + $5) $4 $5
- hadd rexs $1 $2-
- :>
- drawdot -nr @rex $rgb(64,64,128) 3 $2 $3
- :<
- inc %x
- }
- ;angulo do vetor
- var %ang = $round($point_direction($hget(rex,x),$hget(rex,y),$mouse.x,$mouse.y),4)
- ;nave
- drawrect -rnef @rex $rgb(64,128,64) 1 $calc($hget(rex,x) -5) $calc($hget(rex,y) -5) 11 11
- drawrect -rnef @rex $rgb(64,128,64) 1 $calc($hget(rex,x) -3 + $cos(%ang).deg * -5) $calc($hget(rex,y) -3 + $sin(%ang).deg * -5) 7 7
- ;mouse
- drawrect -rne @rex $rgb(128,64,64) 1 $calc($mouse.x -5) $calc($mouse.y -5) 11 11
- drawrect -rne @rex $rgb(128,64,64) 1 $calc($mouse.x -9) $calc($mouse.y -9) 19 19
- ;linha do mouse
- ;drawline -rn @rex $rgb(255,0,0) 1 $hget(rex,x) $hget(rex,y) $mouse.x $mouse.y
- ;osd
- drawtext -rn @rex 0 tahoma 11 5 5 X: $hget(rex,x)
- drawtext -rn @rex 0 tahoma 11 5 20 Y: $hget(rex,y)
- drawtext -rn @rex 0 tahoma 11 5 35 Âng: %ang $+ °
- drawtext -rn @rex 0 tahoma 11 5 50 Tiros: $hget(rex,shoot)
- drawtext -nr @rex 0 tahoma 11 5 65 Vivos: $hget(rexs,0).item
- drawdot @rex
- }
- }
- /*
- alias point_distance { return $calc((($4 - $2) ^ 2 + ($3 - $1) ^ 2) ^ (1/2)) }
- alias point_direction {
- if ($1 == $3) { return $iif($4 > $2,270,90) }
- return $calc($iif($atan($calc(($4 - $2)/($3 - $1))).deg < 0,$calc($v1 +180),$v1) + $iif($4 > $2 || ($4 == $2 && $3 > $1),180,0))
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement