Board Logo
« Stick Man Humour »

Welcome Guest. Please Login or Register.
Jan 16th, 2018, 3:42pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Stick Man Humour  (Read 1707 times)
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Stick Man Humour
« Thread started on: Jun 19th, 2013, 1:36pm »

Its a while since we ran a challenge but we have a few new coders about and Tsh73 recons we should push you guys into coding something a little different.

Well, we could get fancy and say "vector graphics" or "vector animation"; and we don't mind if someone ends up animating a vector cat - just stickman sounds easier to do. (wikipedia: Stick figure)

So, the challenge, make a stickman; make something funny with it or better yet, make *him* do something.

Make him walk, or run, or play, or even fight (google Xiao Xiao ;) ) - everything goes.

Timing is about two weeks. Lets say up to the 7th July, code submitted up to that date will be included in the Poll to chose the winner ending 14th July.

Tsh73 posts this little gem to wet your appetite and get you started.

Code:
'Welcome, Stickman
'proposal for JB contest

global doPause
doPause = 1
WindowWidth = 420
nomainwin
open "Welcome, Stickman!" for graphics_nsb_nf as #gr
    #gr "down"
    #gr "trapclose [quit]"

    txtX = 170
    txtY = 70
    txt = 1: gosub [putLine]
    gosub [DrawAStickman]
    call pause 600
    txt = txt + 1: gosub [putLine]
    gosub [MakeHimWink]
    call pause 600
    txt = txt + 1: gosub [putLine]
    gosub [MakeHimSmile]
    call pause 600
    txt = txt + 1: gosub [putLine]
    gosub [MakeHimWave]
    call pause 600
    txt = txt + 1: gosub [putLine]
    call pause 300
    txt = txt + 1: gosub [putLine]
    call pause 1000
    txt = txt + 1: gosub [putLine]

    #gr "flush"
wait
'--------------------------------------------------

[putLine]
    #gr "place ";txtX;" ";txtY
    #gr "font arial ";13+txt
    read a$
    #gr "\"; a$ 
    #gr "posxy txtX txtY"
    txt=txt+1
return

[DrawAStickman]
    '100 would be horisontal center, ~50 is a top. So ~200 a height
    'let's do head body legs equal
    'len = 70
    top = 50
    call pause 1000
    #gr "place 100 ";50+70/2
    #gr "circle 35"
    call pause 300
    #gr "line 100 ";50+70;" 100 "; 50+2*70
    call pause 300
    #gr "posxy x y"
    #gr "goto ";x+20;" ";y+70
    call pause 300
    #gr "line ";x;" ";y;" ";x-20;" ";y+70
    call pause 300
    #gr "place 100 ";50+70+10
    #gr "north; turn 160; go 70"
    call pause 300
    #gr "place 100 ";50+70+10
    #gr "north; turn 200; go 70"
    'eyes
    call pause 300
    #gr "place ";100+15;" ";50+70/2-10
    #gr "circle 5"
    call pause 300
    #gr "place ";100-15;" ";50+70/2-10
    #gr "circle 5"
return

[MakeHimWink]
    'Eye radius goes like this:
    '\
    ' \/
    'doPause = 1
    'hide eye
    call pause 1000
    #gr "color white"
    #gr "place ";100-15;" ";50+70/2-10
    #gr "circle 5"
    #gr "color black"
    #gr "rule xor"  'for animating

    for i = -10 to 5
        #gr "circle ";abs(i) 'draw
        call pause 100
        #gr "circle ";abs(i) 'clear, because of XOR
    next
    'redraw after animating
    #gr "circle 5"
return

[MakeHimSmile]
    'doPause = 1
    call pause 1000
    #gr "place 100 ";top
    'angle goes 5 to 25
    for a = 5 to 25
        call arc "#gr", 100, 50, 55, 0-90-a, 0-90+a
        call pause 100
        call arc "#gr", 100, 50, 55, 0-90-a, 0-90+a
    next
    'redraw after animating
    call arc "#gr", 100, 50, 55, 0-90-a, 0-90+a
return

[MakeHimWave]
    doPause = 1
    call pause 1000
    'hide arm
    #gr "place 100 ";50+70+10
    #gr "north; turn 200; go 70"
    'animate. Angle 200 to 240
    for a = 200 to 240 step 5
        #gr "place 100 ";50+70+10
        #gr "north; turn ";a;"; go 70"
        call pause 100
        #gr "place 100 ";50+70+10
        #gr "north; turn ";a;"; go 70"
    next
    'redraw after animating
    #gr "place 100 ";50+70+10
    #gr "north; turn ";a;"; go 35"
    'elbow
    #gr "posxy x y"
    'animate lower arm
    for a = 255 to 370 step 10
        #gr "place ";x;" ";y
        #gr "north; turn ";a;"; go 35"
        call pause 100
        #gr "place ";x;" ";y
        #gr "north; turn ";a;"; go 35"
    next
    'and back
    for a = 380 to 340 step -10
        #gr "place ";x;" ";y
        #gr "north; turn ";a;"; go 35"
        call pause 100
        #gr "place ";x;" ";y
        #gr "north; turn ";a;"; go 35"
    next
    'redraw after animating
    #gr "place ";x;" ";y
    #gr "north; turn ";a;"; go 35"
return



[quit]
    close #gr
    end

data "Draw a stickman."
data "Make him wink."
data "Make him smile."
data "Make him wave."
data "Make him do"
data "     something."
'data ""
data "Just make him."

sub pause mil
    if doPause=0 then exit sub
    t0=time$("ms")
    do
        'buzy loop
    loop until time$("ms")>=t0+mil
end sub

sub arc handle$, x0, y0, r, a0, a1
    pi = acs(-1)
    'initial point
    t=a0*pi/180
    x=x0+r*cos(t)
    y=y0-r*sin(t)   'y upside down
    #handle$ "place ";x;" ";y
    for a = a0 to a1
        t=a*pi/180
        x=x0+r*cos(t)
        y=y0-r*sin(t)   'y upside down
        #handle$ "goto ";x;" ";y
        print "goto ";x;" ";y
    next
end sub
 


So let your imagination run free, get those lines moving and lets see what you got.
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Stick Man Humour
« Reply #1 on: Jun 21st, 2013, 02:07am »

Any takers?
It don't need to be complex, at all.
And if you are finding yourself doing some tedious work (guilty - my example program was just that), you better sit for a while and think.
Then put that stuff in a sub and call it in a loop.
Something like that ;)

Ok, to keep it alive - some approach to walking:
Code:
'step idea
'v.01 Runnung something.
'   Obviously wrong, to fix.
'v.02: in 01, speed was
'--  --
'  --  --
'But it make look like sidestep (one leg always behing other)
' now?
'   fixed by setting x apart by half step, initially
'v.03: try to use SIN() instead of just +1
'v.04: some legs, across a screen

WindowWidth = DisplayWidth
WindowLeft = 1
nomainwin

open "test walking" for graphics_nsb_nf as #gr
#gr "down"
#gr "trapclose [quit]"
#gr "size 4"
pi = acs(-1)

dim x(1)    'actually 0, 1
y = 250

legSize = 100
stepSize = legSize/1.5

x(0)=30: x(1)=x(0)-1.3*stepSize/2   '1.3: guess: since speed now differs, stepSize/2 doesn't fit
i = 1
    do until x(0)>WindowWidth and x(1) >WindowWidth
    i=i+1
    'nStep = int(i/stepSize)
    'activeLeg = nStep mod 2
    v = sin(i/stepSize*pi)
    activeLeg = v>0
    'clear old
    #gr "color white"
    #gr "set ";x(0);" ";y
    #gr "goto "; midPtX;" "; midPtY
    #gr "goto ";x(1);" ";y
    'move
    x(activeLeg)=x(activeLeg)+abs(2*v)
    'draw
    midPtX=(x(0)+x(1))/2
    'midPtY = y-legSize
    midPtY = y-sqr(legSize^2-((x(1)-x(0))/2)^2) 'this makes midpoint lower then legs are apart.
    '   not much difference in small size / narrow step, though
    #gr "color blue"
    #gr "set ";x(0);" ";y
    #gr "goto "; midPtX;" "; midPtY
    #gr "color red"
    #gr "goto ";x(1);" ";y

    timer 1, [next]
    wait
[next]
    timer 0
    #gr "discard"
loop
notice "Over!"

wait
[quit]
    close #gr
    end
 

EDIT:
obviously it has some problems - since initial step displacement is guess work, there is no way to change (add) speed! Hmmm... should sit and think for a while ;)
EDIT2:
I'm not sure what varable plays "speed" (or "time") in this program.
%)
Ah well.
« Last Edit: Jun 21st, 2013, 02:23am by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
jaba
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1049
xx Re: Stick Man Humour
« Reply #2 on: Jun 21st, 2013, 6:23pm »

I've added a body and head - just to keep moving ahead with this...
Code:
'step idea
'v.01 Runnung something.
'   Obviously wrong, to fix.
'v.02: in 01, speed was
'--  --
'  --  --
'But it make look like sidestep (one leg always behing other)
' now?
'   fixed by setting x apart by half step, initially
'v.03: try to use SIN() instead of just +1
'v.04: some legs, across a screen

WindowWidth = DisplayWidth
WindowLeft = 1
nomainwin

open "test walking" for graphics_nsb_nf as #gr
#gr "down"
#gr "trapclose [quit]"
#gr "size 4"
pi = acs(-1)

dim x(1)    'actually 0, 1
y = 250

legSize = 100
stepSize = legSize/1.5

x(0)=30: x(1)=x(0)-1.3*stepSize/2   '1.3: guess: since speed now differs, stepSize/2 doesn't fit
i = 1
    do until x(0)>WindowWidth and x(1) >WindowWidth
    i=i+1
    'nStep = int(i/stepSize)
    'activeLeg = nStep mod 2
    v = sin(i/stepSize*pi)
    activeLeg = v>0
    'clear old
    #gr "color white"
    #gr "set ";x(0);" ";y
    #gr "goto "; midPtX;" "; midPtY

'erase body and head
    #gr "goto "; midPtX;" "; midPtY-70
    #gr "up; goto "; midPtX;" "; midPtY-90
    #gr "down"
    #gr "circle 20"
    #gr "set "; midPtX;" "; midPtY
'end erase body and head

    #gr "goto ";x(1);" ";y
    'move
    x(activeLeg)=x(activeLeg)+abs(2*v)
    'draw
    midPtX=(x(0)+x(1))/2
    'midPtY = y-legSize
    midPtY = y-sqr(legSize^2-((x(1)-x(0))/2)^2) 'this makes midpoint lower then legs are apart.
    '   not much difference in small size / narrow step, though
    #gr "color blue"
    #gr "set ";x(0);" ";y
    #gr "goto "; midPtX;" "; midPtY

'body and head added
    #gr "goto "; midPtX;" "; midPtY-70
    #gr "up; goto "; midPtX;" "; midPtY-90
    #gr "down"
    #gr "circle 20"
    #gr "set "; midPtX;" "; midPtY
'end body and head

    #gr "color red"
    #gr "goto ";x(1);" ";y

    timer 1, [next]
    wait
[next]
    timer 0
    #gr "discard"
loop
notice "Over!"

wait
[quit]
    close #gr
    end
 
User IP Logged

JACK - Windows 8.1 64-bit; 2.5 GHz Intel i3 processor; 6.00 GB RAM;
jaba
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1049
xx Re: Stick Man Humour
« Reply #3 on: Jun 23rd, 2013, 2:22pm »

Building on tsh73s walking man:
Code:

WindowWidth = 600'DisplayWidth
WindowLeft = 1
nomainwin

open "test walking" for graphics_nsb_nf as #gr
#gr "down"
#gr "trapclose [quit]"
#gr "size 4"
pi = acs(-1)

dim x(1)    'actually 0, 1
y = 250

legSize = 100
stepSize = legSize/1.5

x(0)=30: x(1)=x(0)-1.3*stepSize/2   '1.3: guess: since speed now differs, stepSize/2 doesn't fit
i = 1
'    do until x(0)>WindowWidth and x(1) >WindowWidth
    do until x(0)>WindowWidth/2 and x(1) >WindowWidth/2
    i=i+1
    'nStep = int(i/stepSize)
    'activeLeg = nStep mod 2
    v = sin(i/stepSize*pi)
    activeLeg = v>0
    'clear old
    #gr "color white"
    #gr "set ";x(0);" ";y
    #gr "goto "; midPtX;" "; midPtY
    #gr "goto "; midPtX;" "; midPtY-70
    #gr "up; goto "; midPtX;" "; midPtY-90
    #gr "down"
    #gr "circle 20"

gosub [arms]

    #gr "set "; midPtX;" "; midPtY
    #gr "goto ";x(1);" ";y
    'move
    x(activeLeg)=x(activeLeg)+abs(2*v)
    'draw
    midPtX=(x(0)+x(1))/2
    'midPtY = y-legSize
    midPtY = y-sqr(legSize^2-((x(1)-x(0))/2)^2) 'this makes midpoint lower then legs are apart.
    '   not much difference in small size / narrow step, though
    #gr "color blue"
    #gr "set ";x(0);" ";y
    #gr "goto "; midPtX;" "; midPtY
    #gr "goto "; midPtX;" "; midPtY-70
    #gr "up; goto "; midPtX;" "; midPtY-90
    #gr "down"
    #gr "circle 20"

    gosub [arms]

    #gr "set "; midPtX;" "; midPtY
'    #gr "color red"
    #gr "goto ";x(1);" ";y

    timer 1, [next]
    wait
[next]
    timer 0
    #gr "discard"
loop

gosub [dropbox]

gosub [shame]
    #gr "up; goto "; midPtX;" "; midPtY-82
    #gr "down"
    #gr "size 2; circle 5"

'notice "Over!"

wait
[quit]
    close #gr
    end

[arms]
    #gr "up; goto "; midPtX;" "; midPtY-50
    #gr "down; goto "; midPtX+35;" ";midPtY-30
    #gr "goto "; midPtX+60;" "; midPtY-40
    #gr "posxy boxCorX boxCorY"

    #gr "box "; boxCorX+40;" ";boxCorY-40
    return

[dropbox]
    #gr "color white"
    #gr "set ";boxCorX;" "; boxCorY
    #gr "box "; boxCorX+40;" ";boxCorY-40
    #gr "color blue"
    for i = 1 to 5
        #gr "set ";boxCorX;" "; boxCorY+(i*20)
        #gr "box "; boxCorX+40;" ";boxCorY+(i*20)+40

            timer 150, [nextdrop]
    wait
    [nextdrop]
    timer 0
        if i = 5 then [nextwhite]
        #gr "color white"
        #gr "set ";boxCorX;" "; boxCorY+(i*20)
        #gr "box "; boxCorX+40;" ";boxCorY+(i*20)+40

            timer 50, [nextwhite]
    wait
    [nextwhite]
    timer 0
        #gr "color blue"

    next i
    #gr "set 360 220; font 20 bold"
    #gr "\crash"
return

[shame]
    #gr "up; goto "; midPtX;" "; midPtY-50
    #gr "down; goto "; midPtX-35;" ";midPtY-55
    #gr "goto "; midPtX-20;" "; midPtY-80
    return

 
User IP Logged

JACK - Windows 8.1 64-bit; 2.5 GHz Intel i3 processor; 6.00 GB RAM;
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Stick Man Humour
« Reply #4 on: Jun 24th, 2013, 01:01am »

LOL nice wink
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
jaba
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1049
xx Re: Stick Man Humour
« Reply #5 on: Jun 26th, 2013, 3:37pm »

Stickman jumping rope.

06/27/13 MODIFICATIONS MADE TO CODE:
  • Changed direction rope turns, so he is not swinging rope backwards.
  • Added pause sub and eliminated timer pauses.

Code:
WindowWidth = 500
WindowHeight = 500
nomainwin

open "Jumping rope" for graphics_nsb_nf as #gr
    #gr "trapclose [quit]"
    #gr "\\loop runs 10 times"

    #gr "home; posxy ctrX ctrY"     'get x,y position of center of window
    #gr "down; size 3"
    #gr "color green; line 0 403 500 403; color black"

    gosub [drawkidIntro]

    #gr "north; turn 180"       'rope points south

    for j = 1 to 10
'        for i = 10 to 360 step 10
        for i = 360 to 10 step -10  'changed direction rope turns
            #gr "turn ";i;"; go 150; color white"

            call Pause 20

            #gr "turn 180; goto "; ctrX;" ";ctrY;"; color black"    'erase rope
            'rope passing over figure destroys figure
            'so, redraw figure after each iteration
            if i = 0 or i < 270 then
                gosub [drawkid]
              else
                gosub [drawkidUp]   'jump for rope
            end if
        next i
    next j
    fini = 1
    gosub [drawkidIntro]
    wait

[drawkid]
    #gr "north; turn 120; go 20; turn -80; go 30"   'arm
    #gr "place 285 295; goto 285 200"               'body
    #gr "place 285 180; circle 20"                  'head
    'erase bent legs
    #gr "place 285 370; color white; goto 270 340; goto 285 295; color black"
    #gr "place 285 400; goto 285 295"               'legs

    #gr "home; north; turn 180"     'start rope pointing south again

    return

[drawkidUp]
    #gr "north; turn 120; go 20; turn -80; go 30"
    #gr "place 285 295; goto 285 200"
    #gr "place 285 180; circle 20"
    'erase straight legs
    #gr "place 285 400; color white; goto 285 295; color black"
    #gr "place 285 370; goto 270 340; goto 285 295" 'draw bent legs
    #gr "home; north; turn 180"

    return

[quit]
    close #gr
    end

sub Pause mil
    t=time$("ms")
    while time$("ms")<t+mil
    wend
    end sub


[drawkidIntro]
    #gr "home; north; turn 120; go 20; turn -80; go 30"   'arm
    #gr "place 285 295; goto 285 200"               'body
    #gr "place 285 180; circle 20"                  'head
    'erase bent legs
    #gr "place 285 370; color white; goto 270 340; goto 285 295; color black"
    #gr "place 285 400; goto 285 295"               'legs
    'draw rope in starting position pointing south
    #gr "home; north; turn 180; go 150"

    call Pause 1000

    'erase rope if not last loop
    if fini = 0 then
        #gr "turn 180; color white; go 150"
      else
        #gr "place 230 180"
        #gr "\Bye"
    end if

    return

 
« Last Edit: Jun 27th, 2013, 3:44pm by jaba » User IP Logged

JACK - Windows 8.1 64-bit; 2.5 GHz Intel i3 processor; 6.00 GB RAM;
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Stick Man Humour
« Reply #6 on: Jun 27th, 2013, 01:05am »

He is jiumping backwards! o_O wink))
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Stick Man Humour
« Reply #7 on: Jun 27th, 2013, 01:42am »

Stickman goes around the Earth!
Code:
'Stickman##.bas
'minimize, parametrize, make a sub
'convert to turtle (so it preserve angle) (default is up - north)

global doPause
doPause = 1
WindowWidth = 500
WindowHeight = 500
nomainwin
open "Stickman goes round the Earth" for graphics_nsb_nf as #gr
    #gr "down"
    #gr "trapclose [quit]"

    s.top = 50
    s.xCntr = 100
    s.height=210
    pi = acs(-1)

    'earth
    cx = 250: cy = 250
    #gr "place ";cx;" ";cy
    r=100
    #gr "circle ";r
    #gr "go 100; go -200; go 100; turn 90; go 100; go -200"

    'now this one was tricky to get right
    pi = acs(-1)
    for i = 1/4 to 3/4 step 1/4
        dx = r*i
        dx2 = r*r/dx
        cxx=cx-dx/2+dx2/2
        rr=(dx+dx2)/2
        a = 2*atan2(r, dx2)
        for f=pi-a to pi+a step 1/rr
            x=cxx+rr*cos(f)
            y=cy+rr*sin(f)
            #gr "set ";x;" ";y
            x=2*cx-cxx-rr*cos(f)
            #gr "set ";x;" ";y
        next
    next

    for i = 1/4 to 3/4 step 1/4
        a = pi/2*i
        rr=r/tan(a)
        cyy=cy+r/sin(a)
        for f=0-pi/2-a to 0-pi/2+a step 1/rr
            x=cx+rr*cos(f)
            y=cyy+rr*sin(f)
            #gr "set ";x;" ";y
            y=2*cy-cyy-rr*sin(f)
            #gr "set ";x;" ";y
        next
    next

    #gr "rule xor"
    #gr "north"

    nPts = 120
    for i = 0 to nPts-1
        a = 2*pi/nPts*i-pi/2
        height=150*(i+1)/(nPts+1)
        x=cx+100*cos(a)
        y=cy+100*sin(a)    'upper point of stickman
        #gr "place ";x;" ";y
        '#gr "circle 10"

        call StickmanLo x, y, height    'draw
        call pause 20
        'skip some
        if i mod 10 <>0 then
            call StickmanLo x, y, height    'clear
        end if

        #gr "turn ";360/nPts    'should be integer. Or will differ.
    next
    call StickmanLo x, y, height    'redraw last time

    #gr "flush"
wait

[quit]
    close #gr
end

sub StickmanLo s.xCntr, s.Bottom, s.height
    #gr "place ";s.xCntr;" ";s.Bottom
    #gr "up; go ";s.height;"; down"
    #gr "posxy newXCntr top"
print s.xCntr, s.Bottom, dummy, top
    call Stickman newXCntr, top, s.height
end sub

sub Stickman s.xCntr, s.top, s.height
'let's do head body legs equal, s.len
    s.len = s.height/3
    s.r = s.len/2

    'head
    #gr "place ";s.xCntr;" ";s.top
    #gr "up; go ";0-s.r;"; down"
    #gr "circle ";s.r
    'body
    #gr "up; go ";0-s.r;"; down"
    #gr "go ";0-s.len
    'legs
    legAngle = 15   'from "down" direction.
    #gr "posxy legsX legsY"
    #gr "turn ";180-legAngle;"; go ";s.len
    #gr "place ";legsX;" ";legsY
    #gr "turn ";2*legAngle;"; go ";s.len
    'arms
    #gr "turn ";0-legAngle  'now points down
    armAngle = 20
    #gr "place ";s.xCntr;" ";s.top
    #gr "up; go ";(1+1/7)*s.len;"; down"
    #gr "posxy armsX armsY"
    #gr "turn ";0-armAngle;"; go ";s.len
    #gr "place ";armsX;" ";armsY
    #gr "turn ";2*armAngle;"; go ";s.len
    #gr "turn ";0-armAngle 'now points down
    'eyes
    s.rr=s.r/7
    #gr "place ";s.xCntr;" ";s.top
    #gr "turn 25; up; go ";s.r;"; down"
    #gr "circle ";s.rr
    #gr "place ";s.xCntr;" ";s.top
    #gr "turn -50; up; go ";s.r;"; down"
    #gr "circle ";s.rr
    #gr "turn 25"  'now points down
    'smile
    #gr "place ";s.xCntr;" ";s.top
    #gr "up; go ";4/5*s.len;"; down"
    #gr "posxy mouthX mouthY"
    #gr "turn 100; go ";s.r/4
    #gr "turn 10; go ";s.r/4
    #gr "place ";mouthX ;" ";mouthY
    #gr "turn -210; go ";s.r/4
    #gr "turn -10; go ";s.r/4

    #gr "turn -70"
'    #gr "go 100"  'check that points as before - north
end sub

'--------------------------------------------
sub pause mil
    if doPause=0 then exit sub
    t0=time$("ms")
    do
        'buzy loop
    loop until time$("ms")>=t0+mil
end sub

'-------------------------------------------
function atan2(y,x)
    pi = asn(1) * 2
    if x <> 0 then arctan = atn(y/x)

    select case
        case x > 0
        atan2 = arctan

        case y>=0 and x<0
        atan2 = pi + arctan

        case y<0 and x<0
        atan2 = arctan - pi

        case y>0 and x=0
        atan2 = pi / 2

        case y<0 and x=0
        atan2 = pi / -2
    end select
end function
 
« Last Edit: Jun 27th, 2013, 01:46am by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
jaba
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1049
xx Re: Stick Man Humour
« Reply #8 on: Jun 27th, 2013, 2:41pm »

on Jun 27th, 2013, 01:05am, tsh73 wrote:
He is jiumping backwards! o_O wink))

Details, details! I think I'll fix him... tongue

EDIT: Made changes to code in Reply #5.
« Last Edit: Jun 27th, 2013, 3:45pm by jaba » User IP Logged

JACK - Windows 8.1 64-bit; 2.5 GHz Intel i3 processor; 6.00 GB RAM;
jaba
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1049
xx Re: Stick Man Humour
« Reply #9 on: Jun 27th, 2013, 2:45pm »

tsh73 Quote:
Stickman goes around the Earth!

Great! What an amazing amount of work...
User IP Logged

JACK - Windows 8.1 64-bit; 2.5 GHz Intel i3 processor; 6.00 GB RAM;
jaba
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1049
xx Re: Stick Man Humour
« Reply #10 on: Jul 1st, 2013, 12:54pm »

Stickman goes skateboarding. A little crude, but has lots of animation.
Code:
WindowWidth = 500
WindowHeight = 500
nomainwin

global ctrX, ctrY, faceH, faceY

open "Stickman goes skateboarding" for graphics_nsb_nf as #gr
    #gr "trapclose [quit]"

    #gr "home; posxy ctrX ctrY"
    #gr "size 3; down"

    call greenline
    'draw bracket
    #gr "place 0 104; goto 80 104; goto 0 150"
    call droprope
    call Pause 1000
    call slideplank
    call onplank
    call downrope
    'erase rope
    #gr "color white; place ";ctrX;" ";17;";north; turn 180; go 300"
    call greenline

    call jumploop
    call eraseKid

    call greenline
    call Pause 250

    'finish with skate board
    oldctrX = ctrX
    for t = 1 to 9
        #gr "color black"
        for erase = 1 to 2
            #gr "size 10; set ";ctrX;" ";397;";set ";ctrX+35;" ";397
            #gr "size 4; place ";ctrX-15;" ";390
            #gr "goto ";ctrX+50;" ";390
            if t mod 2 = 0 then
                call skateKid 1
              else
                call skateKid 0
            end if
            call Pause 150
            if t < 9 then #gr "color white"
        next erase
        ctrX = ctrX-40
    next t
    'get center X back
    ctrX = oldctrX

wait

[quit]
    close #gr
    end
'================================================================

sub Pause mil
    t=time$("ms")
    while time$("ms")<t+mil
    wend
    end sub

sub greenline
    #gr "color green; line 0 403 500 403; color black"
    end sub

sub droprope
    #gr "place ";ctrX-10;" ";-5
    #gr "circle 20"
    #gr "place ";ctrX;" ";15
    y=0
    while y < 300
        y=y+50
        #gr "goto ";ctrX;" ";y
        call Pause 500
    wend
    end sub

sub slideplank
    h= -3
    #gr "size 4"
    #gr "place 0 101"
    while h < ctrX-30
        h=h+3
        #gr "set ";h;" ";101
        call Pause 20
    wend
    #gr "size 3"
    end sub

sub onplank
    footH = -100
    cnt = 0
    while footH < 75
        cnt = cnt +1
        #gr "color black"
        footH = footH +10
        call crawl footH, cnt
        call Pause 100
        if footH > 50 then
            call blink faceH, faceY
        end if
        #gr "color white"
        call crawl footH, cnt
    wend
    end sub

sub crawl ft, num
    if num mod 2 <> 0 then
        #gr "place ";ft;" ";95
        #gr "goto "; ft+30;" ";97
        #gr "goto "; ft+40;" ";50
        #gr "goto "; ft+115;" ";50
        #gr "place "; ft+135;" ";50:faceH=ft+145: faceY=50
        #gr "circle 20"
        #gr "place ";ft+110;" ";50
        #gr "goto "; ft+115;" ";97
      else
        #gr "place ";ft+30;" ";95
        #gr "goto "; ft+60;" ";97
        #gr "goto "; ft+40;" ";50
        #gr "goto "; ft+115;" ";50
        #gr "place "; ft+135;" ";50
        #gr "circle 20"
        #gr "place ";ft+105;" ";50
        #gr "goto "; ft+130;" ";97
    end if
    end sub

sub blink fH, fY
    #gr "size 1"
    for eye = 1 to 2
        #gr "place "; fH-8;" ";fY
        #gr "circle 4"
        #gr "place "; fH+8;" ";fY
        #gr "circle 4"
        call Pause 1000
        #gr "color white"
        #gr "place "; fH-8;" ";fY
        #gr "circle 4"
        #gr "place "; fH+8;" ";fY
        #gr "circle 4"
        call Pause 100
        #gr "color black"
    next eye
    #gr "size 3"
    end sub

sub downrope
    y=20
    top=0
    while y < 200'250
        top=top+1
        #gr "color black"
        y = y+18
        call climbDown top, y
        call Pause 500
        #gr "color white"
        call climbDown top, y
    wend
    end sub

sub climbDown hand, ypos
    if hand mod 2 <> 0 then
        #gr "place "; ctrX+2;" ";ypos
        #gr "goto ";ctrX+15;" ";ypos+10
        #gr "goto ";ctrX+30;" ";ypos
        #gr "goto ";ctrX+15;" ";ypos+20
        #gr "goto ";ctrX+2;" ";ypos+40
        #gr "place ";ctrX+30;" ";ypos-35
        #gr "circle 20"
        #gr "place ";ctrX+30;" ";ypos-15
        #gr "north; turn 180; go 180"
      else
        #gr "place ";ctrX+2;" ";ypos+20
        #gr "goto ";ctrX+30;" ";ypos+30
        #gr "goto ";ctrX+10;" ";ypos+40
        #gr "goto "; ctrX+2;" ";ypos+30
        #gr "place ";ctrX+30;" ";ypos-5
        #gr "circle 20"
        #gr "place ";ctrX+30;" ";ypos+15
        #gr "north; turn 180; go 180"
    end if
    end sub

sub jumploop
    #gr "color black"
    #gr "place ";ctrX;" ";ctrY+5
    for j = 1 to 10
        for i = 360 to 10 step -10
            #gr "turn ";i;"; go 135; color white"

            call Pause 20

            #gr "turn 180; goto "; ctrX;" ";ctrY+5;"; color black"    'erase rope
            call drawKid i
        next i
    next j
    end sub

sub drawKid dir
    #gr "place ";ctrX;" ";ctrY+5
    #gr "north; turn 120; go 20; turn -70; go 27"   'arm
    #gr "place 285 295; goto 285 220"'200"          'body 75
    #gr "place 285 200; circle 20"                  'head 20pix radius
    if dir = 0 or dir < 270 then
        'erase bent legs
        #gr "place 285 370; color white; goto 270 340; goto 285 295; color black"
        #gr "place 285 400; goto 285 295"           'legs
      else
        'erase straight legs
        #gr "place 285 400; color white; goto 285 295; color black"
        #gr "place 285 370; goto 270 340; goto 285 295" 'draw bent legs
    end if
    #gr "place ";ctrX;" ";ctrY+5;"; north; turn 180"     'start rope pointing south again
    end sub

sub eraseKid
    #gr "color white"
    #gr "place ";ctrX;" ";ctrY+5
    #gr "north; turn 120; go 20; turn -70; go 27"   'arm
    #gr "place 285 295; goto 285 220"               'body
    #gr "place 285 200; circle 20"                  'head
    #gr "place 285 400; goto 285 295"               'legs
    end sub

sub skateKid push
    #gr "size 3"
    #gr "place ";ctrX-10;" ";ctrY+40
    #gr "north; turn 80; go 20; turn -50; go 33"               'arm
    #gr "place ";ctrX+35;" "; 310;";goto ";ctrX+25;" ";230     'body
    #gr "place ";ctrX+25;" ";210;";circle 20"                  'head 20pix radius

    #gr "place ";ctrX+30;" ";390;";goto ";ctrX+25;" ";355;";goto ";ctrX+35;" ";310

    if push = 1 then
        #gr "goto ";ctrX+65;" ";397
      else
        #gr "goto ";ctrX+20;" ";400
    end if
    end sub
 
User IP Logged

JACK - Windows 8.1 64-bit; 2.5 GHz Intel i3 processor; 6.00 GB RAM;
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls