Author Topic: Troll  (Read 1977 times)

Cosmo

  • Guest
Troll
« on: June 18, 2013, 07:44:25 PM »
Hi,

here is a simple NaLaa program. just move the mouse.
Code: [Select]
import "speed.lib"
import "library.lib"

set window 0,0,640,480
set redraw off

visible:
x#;y#;rot#;vel#;tx;ty;dx#;dy#;angle#;dist#;da#;kurbis;zK;vK#;xfont

pumpa = LoadBmp("bmp/pumpa.bmp",0,0)
xfont = LoadBmp("bmp/afont.bmp",16,6)
radians

while keydown(27)=0
proc ClsColor 255,255,255
tx = mousex()
ty = mousey()
dx = float(tx)-x
dy = float(ty)-y
dist = sqr(dx*dx+dy*dy)
angle = atan2(float(ty)-y,float(tx)-x)
da = angle-rot
da = atan2(sin(da),cos(da))
vel = Min(1.0, dist/100.0)
rot=rot + da*vel*0.1
x=x + cos(rot)*vel*5.0
y=y + sin(rot)*vel*5.0
proc SetBmp pumpa,int(x)-5,int(y)-5,zK
proc iText xfont,"TROLL",196,16
vK = vK + 0.2
if vK > 1.0
   vK = 0.0
   zK = zK +1
   if zK=16 then zK=0
endif

redraw
proc SPD_HoldFrame 60
wend

function Min#(a#,b#)
if a <= b 
   return a
else
   return b
endif   
endfunc

kevin

  • Guest
Re: Troll
« Reply #1 on: June 18, 2013, 08:38:22 PM »
very good.....I think I need to read up on trigonometry though!......