Board Logo
« PIEs are for PACK-MAN »

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


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: PIEs are for PACK-MAN  (Read 82 times)
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx PIEs are for PACK-MAN
« Thread started on: Dec 23rd, 2017, 2:38pm »

It looks I found good use for PIE drawing command ;)
Code:
'using PIEs to do the PACK-MAN
'tsh73 Dec 2017
nomainwin
WindowWidth=600
WindowHeight=600
UpperLeftX=1
UpperLeftY=1

tgX = -100: tgY = -100   'target, initially offscreen
size = 100
R = size/2
RPellet=10

open "PIEs are for PACK-MAN!" for graphics as #gr
#gr "trapclose [quit]"
#gr "down; home"
#gr "posxy cx cy"
x=cx: y=cy

#gr "when leftButtonDown [clk]"
timer 30, [nxt]

gap=60
while ang < 10000
    wait
[nxt]
    if tgX<0 then '[draw]
        tgX = R+rnd(1)*(2*cx-R)
        tgY = R+rnd(1)*(2*cy-R)
    end if
    'calc next position
    dx=tgX-x
    dy=tgY-y
    d=sqr(dx^2+dy^2)    'length
    if d<R then 'remove target
        tgX = -100: tgY = -100
        vx=0: vy=0
    else
        vx=dx/d*3
        vy=dy/d*3   'speed as a vector, length 3
        'ang = ang+2
        ang = atan2(dy, dx) * 180 / acs(-1)
        x=x+vx
        y=y+vy
    end if
[draw]
    'draw
    #gr "cls"
    gapState = gapState+1
    gap = Abs(50 * Sin(gapState / 2))
    #gr "backcolor yellow"
    #gr "color black"     'black outlne looks better
    #gr "place ";x;" ";y
    #gr "piefilled ";size;" ";size;" ";ang+gap/2;" ";360-gap
    if tgX>=0 then  'drawPellet
        #gr "backcolor red"
        #gr "color red"
        #gr "place ";tgX;" ";tgY
        #gr "circlefilled ";RPellet
    end if
wend
timer 0
#gr "flush"
wait

[clk]
    tgX=MouseX
    tgY=MouseY
wait

[quit]
close #gr
end

'-------------------------------------
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
 
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)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1255
xx Re: PIEs are for PACK-MAN
« Reply #1 on: Dec 23rd, 2017, 2:52pm »

Hi tsh,

cheesy Ha very cute! I bet I know who loves this one, kid approved?
User IP Logged

B+
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