Running Man

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Running Man

Post by DrChip »

Code: Select all

REM Running man demo
REM 
REM touch to run on the spot (bug)
REM touch to show skeleton
REM iPhone 6 Plus / 8.3 b4
REM Enjoy...

graphics

gosub setup

loop: 
refresh off
    graphics clear 0,0,0
    
    for i=3 to 0 step-1
    ka=30*sn(rp)
    kx1=leg*sn(160+ka)
    ky1=-leg*cs(160+ka)
    kx2=leg*sn(160-ka)
    ky2=-leg*cs(160-ka)
    aa=80*sn((rp+320)%360)
    ax1=leg*sn(220+aa)
    ay1=-leg*cs(220+aa)
    ax2=leg*sn(220-aa)
    ay2=-leg*cs(220-aa)
    bx1=kx1/6-3
    bx2=kx2/6-3
    sx1=sho*sn(180-ka)*sn(ba+45)
    sy1=sho*sn(180-ka)*cs(ba+45)
    sx2=sho*sn(180+ka)*sn(ba+45)
    sy2=sho*sn(180+ka)*cs(ba+45)
    sx=back*sn(ba)
    sy=-back*cs(ba)
    wa=70*sn((rp+30)%360)
    ex1=arm*sn(180-ka)
    ey1=-arm*cs(180-ka)
    ex2=arm*sn(180+ka)
    ey2=-arm*cs(180+ka)
    wx1=arm*sn(90-wa)
    wy1=-arm*cs(90-wa)
    wx2=arm*sn(90+wa)
    wy2=-arm*cs(90+wa)
    na=30+10*sn((90+rp*2)%360)
    hx=neck*sn(na)
    hy=-neck*cs(na)
fill color (140-i*30)/255,(80-i*30)/255,(80-i*30)/255
tx=x+kx1
ty=y+ky1
'fill triangle x+ky1/4,y-kx1/4 to x-ky1/4,y+kx1/4 to tx+ky1/5,ty-kx1/5
trix(0)=x+ky1/4
triy(0)=y-kx1/4
trix(1)=x-ky1/4
triy(1)=y+kx1/4
trix(2)=tx+ky1/5
triy(2)=ty-kx1/5
fill poly trix,triy count 3
'fill triangle tx+ky1/5,ty-kx1/5 to tx-ky1/5,ty+kx1/5 to x-ky1/4,y+kx1/4
trix(0)=tx+ky1/5
triy(0)=ty-kx1/5
trix(1)=tx-ky1/5
triy(1)=ty+kx1/5
trix(2)=x-ky1/4
triy(2)=y+kx1/4
fill poly trix,triy count 3
fill circle tx,ty size leg/5
tx=tx+ax1
ty=ty+ay1
'fill triangle x+kx1+ay1/5,y+ky1-ax1/5 to x+kx1-ay1/5,y+ky1+ax1/5 to tx+ay1/8,ty-ax1/8
trix(0)=x+kx1+ay1/5
triy(0)=y+ky1-ax1/5 
trix(1)=x+kx1-ay1/5
triy(1)=y+ky1+ax1/5
trix(2)=tx+ay1/8
triy(2)=ty-ax1/8
fill poly trix,triy count 3
'fill triangle tx+ay1/8,ty-ax1/8 to tx-ay1/8,ty+ax1/8 to x+kx1-ay1/5,y+ky1+ax1/5
fy1=min(350,ty-ax1*.6)
trix(0)=tx+ay1/8
triy(0)=ty-ax1/8
trix(1)=tx-ay1/8
triy(1)=ty+ax1/8
trix(2)=x+kx1-ay1/5
triy(2)=y+ky1+ax1/5
fill poly trix,triy count 3
'fill triangle tx,ty to x+kx1+ax1*.7,y+ky1+ay1*.7 to tx+ay1*.6,fy1
trix(0)=tx
triy(0)=ty
trix(1)=x+kx1+ax1*.7 
triy(1)=y+ky1+ay1*.7
trix(2)=tx+ay1*.6
triy(2)=fy1
fill poly trix,triy count 3
fill circle x+bx1,y size leg/3.5
tx=x+sx+sx1
ty=y+sy+sy1
fill circle tx,ty size arm/3
'fill triangle tx+ey1/3,ty-ex1/3 to tx-ey1/3,ty+ex1/3 to tx+ex1+ey1/4,ty+ey1-ex1/4
trix(0)=tx+ey1/3
triy(0)=ty-ex1/3 
trix(1)=tx-ey1/3
triy(1)=ty+ex1/3
trix(2)=tx+ex1+ey1/4
triy(2)=ty+ey1-ex1/4
fill poly trix,triy count 3
'fill triangle tx-ey1/3,ty+ex1/3 to tx+ex1+ey1/4,ty+ey1-ex1/4 to tx+ex1-ey1/4,ty+ey1+ex1/4
trix(0)=tx-ey1/3
triy(0)=ty+ex1/3
trix(1)=tx+ex1+ey1/4
triy(1)=ty+ey1-ex1/4
trix(2)=tx+ex1-ey1/4
triy(2)=ty+ey1+ex1/4
fill poly trix,triy count 3
tx=tx+ex1
ty=ty+ey1
fill circle tx,ty size arm/4
'fill triangle tx+wy1/4,ty-wx1/4 to tx-wy1/4,ty+wx1/4 to tx+wx1+wy1/6,ty+wy1-wx1/6
trix(0)=tx+wy1/4
triy(0)=ty-wx1/4
trix(1)=tx-wy1/4
triy(1)=ty+wx1/4
trix(2)=tx+wx1+wy1/6
triy(2)=ty+wy1-wx1/6
fill poly trix,triy count 3
'fill triangle tx-wy1/4,ty+wx1/4 to tx+wx1-wy1/6,ty+wy1+wx1/6 to tx+wx1+wy1/6,ty+wy1-wx1/6
trix(0)=tx-wy1/4
triy(0)=ty+wx1/4
trix(1)=tx+wx1-wy1/6
triy(1)=ty+wy1+wx1/6
trix(2)=tx+wx1+wy1/6
triy(2)=ty+wy1-wx1/6
fill poly trix,triy count 3
fill circle tx+wx1,ty+wy1 size arm/4
fill color (150-i*30)/255,(90-i*30)/255,(90-i*30)/255
tx=x+sx
ty=y+sy
'fill triangle tx-sy/4,ty+sx/4 to tx+sy/4,ty-sx/4 to tx+hx,ty+hy
trix(0)=tx-sy/4
triy(0)=ty+sx/4
trix(1)=tx+sy/4
triy(1)=ty-sx/4
trix(2)=tx+hx
triy(2)=ty+hy
fill poly trix,triy count 3
'fill triangle tx+sy/4,ty-sx/4 to tx+hx,ty+hy to tx+hx+hy/3,ty+hy-hx/3
trix(0)=tx+sy/4
triy(0)=ty-sx/4
trix(1)=tx+hx
triy(1)=ty+hy 
trix(2)=tx+hx+hy/3
triy(2)=ty+hy-hx/3
fill poly trix,triy count 3
fill circle tx+hx,ty+hy size neck/2
'fill triangle x-sy/5,y+sx/5 to x+sy/5,y-sx/5 to tx-sy/4,ty+sx/4
trix(0)=x-sy/5
triy(0)=y+sx/5
trix(1)=x+sy/5
triy(1)=y-sx/5
trix(2)=tx-sy/4
triy(2)=ty+sx/4
fill poly trix,triy count 3
'fill triangle x+sy/5,y-sx/5 to tx-sy/4,ty+sx/4 to tx+sy/4,ty-sx/4
trix(0)=x+sy/5
triy(0)=y-sx/5
trix(1)=tx-sy/4
triy(1)=ty+sx/4
trix(2)=tx+sy/4
triy(2)=ty-sx/4
fill poly trix,triy count 3
fill color (160-i*30)/255,(100-i*30)/255,(100-i*30)/255
tx=x+kx2
ty=y+ky2
'fill triangle x+ky2/4,y-kx2/4 to x-ky2/4,y+kx2/4 to tx+ky2/5,ty-kx2/5
trix(0)=x+ky2/4
triy(0)=y-kx2/4
trix(1)=x-ky2/4
triy(1)=y+kx2/4
trix(2)=tx+ky2/5
triy(2)=ty-kx2/5
fill poly trix,triy count 3
'fill triangle tx+ky2/5,ty-kx2/5 to tx-ky2/5,ty+kx2/5 to x-ky2/4,y+kx2/4
trix(0)=tx+ky2/5
triy(0)=ty-kx2/5
trix(1)=tx-ky2/5
triy(1)=ty+kx2/5
trix(2)=x-ky2/4
triy(2)=y+kx2/4
fill poly trix,triy count 3
fill circle tx,ty size leg/5
tx=tx+ax2
ty=ty+ay2
'fill triangle x+kx2+ay2/5,y+ky2-ax2/5 to x+kx2-ay2/5,y+ky2+ax2/5 to tx+ay2/8,ty-ax2/8
trix(0)=x+kx2+ay2/5
triy(0)=y+ky2-ax2/5
trix(1)=x+kx2-ay2/5
triy(1)=y+ky2+ax2/5
trix(2)=tx+ay2/8
triy(2)=ty-ax2/8
fill poly trix,triy count 3
'fill triangle tx+ay2/8,ty-ax2/8 to tx-ay2/8,ty+ax2/8 to x+kx2-ay2/5,y+ky2+ax2/5
fy1=min(350,ty-ax2*.6)
trix(0)=tx+ay2/8
triy(0)=ty-ax2/8
trix(1)=tx-ay2/8
triy(1)=ty+ax2/8
trix(2)=x+kx2-ay2/5
triy(2)=y+ky2+ax2/5
fill poly trix,triy count 3
'fill triangle tx,ty to x+kx2+ax2*.7,y+ky2+ay2*.7 to tx+ay2*.6,fy1
trix(0)=tx
triy(0)=ty
trix(1)=x+kx2+ax2*.7
triy(1)=y+ky2+ay2*.7
trix(2)=tx+ay2*.6
triy(2)=fy1
fill poly trix,triy count 3
fill circle x+bx2,y size leg/3.5
tx=x+sx+sx2
ty=y+sy+sy2
fill circle tx,ty size arm/3
'fill triangle tx+ey2/3,ty-ex2/3 to tx-ey2/3,ty+ex2/3 to tx+ex2+ey2/4,ty+ey2-ex2/4
trix(0)=tx+ey2/3
triy(0)=ty-ex2/3
trix(1)=tx-ey2/3
triy(1)=ty+ex2/3
trix(2)=tx+ex2+ey2/4
triy(2)=ty+ey2-ex2/4
fill poly trix,triy count 3
'fill triangle tx-ey2/3,ty+ex2/3 to tx+ex2+ey2/4,ty+ey2-ex2/4 to tx+ex2-ey2/4,ty+ey2+ex2/4
trix(0)=tx-ey2/3
triy(0)=ty+ex2/3
trix(1)=tx+ex2+ey2/4
triy(1)=ty+ey2-ex2/4
trix(2)=tx+ex2-ey2/4
triy(2)=ty+ey2+ex2/4
fill poly trix,triy count 3
fill circle x+sx+sx2+ex2,y+sy+sy2+ey2 size arm/4
tx=tx+ex2
ty=ty+ey2
'fill triangle tx+wy2/4,ty-wx2/4 to tx-wy2/4,ty+wx2/4 to tx+wx2+wy2/6,ty+wy2-wx2/6
trix(0)=tx+wy2/4
triy(0)=ty-wx2/4
trix(1)=tx-wy2/4
triy(1)=ty+wx2/4
trix(2)=tx+wx2+wy2/6
triy(2)=ty+wy2-wx2/6
fill poly trix,triy count 3
'fill triangle tx-wy2/4,ty+wx2/4 to tx+wx2-wy2/6,ty+wy2+wx2/6 to tx+wx2+wy2/6,ty+wy2-wx2/6
trix(0)=tx-wy2/4
triy(0)=ty+wx2/4
trix(1)=tx+wx2-wy2/6
triy(1)=ty+wy2+wx2/6
trix(2)=tx+wx2+wy2/6
triy(2)=ty+wy2-wx2/6
'fill poly trix,triy count 3
fill circle tx+wx2,ty+wy2 size arm/4

if touch_x(0) >0 then
draw color 0,0,0
draw line x,y to x+kx1,y+ky1
draw line x,y to x+kx2,y+ky2
draw line x+kx1,y+ky1 to x+kx1+ax1,y+ky1+ay1
draw line x+kx2,y+ky2 to x+kx2+ax2,y+ky2+ay2
draw line x,y to x+sx,y+sy
draw line x+sx+sx1,y+sy+sy1 to x+sx+sx2,y+sy+sy2
draw line x+sx+sx1,y+sy+sy1 to x+sx+sx1+ex1,y+sy+sy1+ey1
draw line x+sx+sx2,y+sy+sy2 to x+sx+sx2+ex2,y+sy+sy2+ey2
draw line x+sx+sx1+ex1,y+sy+sy1+ey1 to x+sx+sx1+ex1+wx1,y+sy+sy1+ey1+wy1
draw line x+sx+sx2+ex2,y+sy+sy2+ey2 to x+sx+sx2+ex2+wx2,y+sy+sy2+ey2+wy2
draw line x+sx,y+sy to x+sx+hx,y+sy+hy
end if
    rp=(rp+7)%360
    if touch_x(0) <0 then x=((x+100+leg/16)%840)-100
    next i
    rp=(rp+341)%360
    ayp1=y+ky1+ay1
    ayp2=y+ky2+ay2
    my=max(ayp1,ayp2)
    if my>350 then y=y-(my-350)
    if my<350 then y=y+.6
refresh on
goto loop


setup:
    dim trix(4),triy(4)
    pi=3.1415
    sw=screen_width()
    sh=screen_height()
    ss=0
    dim sn(361),cs(361)
    for i=0 to 360
        sn(i)=sin(i/180*pi)
        cs(i)=cos(i/180*pi)
    next i
    rp=0
    x=-100
    y=250
    leg=51
    arm=35
    back=50
    sho=20
    neck=32
    ba=20    
return
Attachments
image.jpg
image.jpg (96.04 KiB) Viewed 1685 times
image.jpg
image.jpg (88.14 KiB) Viewed 1685 times
image.jpg
image.jpg (82.68 KiB) Viewed 1685 times
Last edited by DrChip on Fri Sep 04, 2015 2:32 am, edited 1 time in total.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Running Man

Post by Mr. Kibernetik »

That's great!

DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Re: Running Man

Post by DrChip »

Thanks!

I wanted two fingers to show the bones and a tap to make him run. I haven't looked at the touch syntax yet. :)

Post Reply