Qbasicnews.com
May 20, 2019, 07:23:05 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: Obscurely coded pong  (Read 17899 times)
yetifoot
Ancient Guru
****
Posts: 575



« Reply #30 on: December 18, 2005, 08:37:15 PM »

shocker!!!
Quote
bxs=cos bouncy a)*ms

genuine angles!!
Logged

EVEN MEN OF STEEL RUST.
Deleter
Na_th_an
*****
Posts: 1292



WWW
« Reply #31 on: December 18, 2005, 08:37:25 PM »

ok i know this one doesn't count at all, although how it works is a little obscure even to me (coding on caffiene...). But its fun as heck to play. (you can move up down and left <-> right
Code:
#define pi (3.14/180)
dim shared as single py=240,px,pw=16,ph=64,pys=0,pxs=0,ps=1,bx=320,by=240,bxs,bys,br=10,ms=200,sx=640,sy=480,tm,cs,a,sc,sl=20,a2,pdx
pdx=100
px=pdx
function Distance (x1 as single,y1 as single,x2 as single,y2 as single) as single
    return sqr( ( x1 - x2 ) ^ 2 + ( y1 - y2 ) ^ 2 )
end function
function Angle(x1 as single,y1 as single,x2 as single,y2 as single) as single
    dim as single tempAngle, tempY, tempX
    tempX = x1 - x2
    tempY = y1 - y2
    tempAngle = ( atn ( tempY / tempX ) )/pi
    if tempX < 0 XOR tempY < 0 then tempAngle = tempAngle + 180
    if tempY >= 0 then tempAngle = tempAngle + 180
    return tempAngle
end function
sub resetit()
    ps-=1
    bx=sx/2
    by=sy/2
    py=sy/2
    pys=0
    pxs=0
    px=pdx
    a=(1.5*rnd-.75)+3.14*int(rnd*2)
    bxs=cos(a)*ms
    bys=sin(a)*ms
end sub
sub moveit()
    tm=timer-tm
    if multikey(72) or multikey(80) then pys+=ms*4*tm*sgn(multikey(80)*2-1)
    if multikey(75) or multikey(77) then pxs+=ms*4*tm*sgn(multikey(77)*2-1)
    if abs(pys) > ms then pys=ms*sgn(pys)
    if abs(pxs) > ms then pxs=ms*sgn(pxs)
    py+=pys*tm
    px+=pxs*tm
    pys=(1-tm)*pys
    if px > pdx then pxs-=abs(px-pdx)*tm*ms/8 else pxs+=abs(px-pdx)*tm*ms/8
    pxs=(1-.9*tm)*pxs
    if py < ph*2/3 then
        py=ph*2/3
        pys=-pys
    end if
    if py > sy-ph*2/3 then
        py=sy-ph*2/3
        pys=-pys
    end if
    bx+=bxs*tm
    by+=bys*tm
    if bx >= sx-br then
        bx=sx-br-1
        bxs=-bxs
        ps+=1
    elseif bx-br <= px+(ph*2/3) then
       
        if Distance(px,py,bx,by) <= (ph*2/3+br) then
            a=2*Angle(bx,by,px,py)-Angle(bxs,bys,0,0)
            bxs=cos(a*pi)*ms+pxs/2
            bys=sin(a*pi)*ms+pys/2
            a2=Angle(bx,by,px,py)+180
            bx=cos(a2*pi)*(ph*2/3+br)+px
            by=sin(a2*pi)*(ph*2/3+br)+py
        end if
       
        if bx <= 0 then resetit()
    end if
    if by+br > sy then
        by=sy-br
        bys=-bys
    elseif by < br then
        by=br
        bys=-bys
    end if
    sc+=8*tm
    tm=timer
end sub
sub drawit()
    cls
    color 15,4
    me$="                    Slider Pong Coded By: Deleter  -  Your Score: "+str$(ps)+"        Buy pi!             "
   
    line (sx/2-sl*4-2,-1)-(sx/2+sl*4+2,10),4,bf
    line (sx/2-sl*4-3,-1)-(sx/2+sl*4+3,11),12,b
    line (sx/2-sl*4-4,-1)-(sx/2+sl*4+4,12),4,b  
    locate 1,(sx/16+1)-sl/2
   
    if int (sc)>len(me$)-sl/2 then sc=1
    print mid$(me$,int(sc),int(sl))    
    color ,0
    circle (bx, by), br, 2,,,, F
   
    line (pdx,0)-(px,py),4
    line (pdx,sy)-(px,py),4
    circle(px,py),ph*2/3,4,,,, F
    print int(Distance(bxs,bys,0,0))
end sub
tm=timer
randomize timer
screenres sx,sy,8,2
sleep 10
input "Difficulty? (1=easy, higher=harder)"; ms
ms*=100
resetit
do
    moveit
    drawit
    sleep 1,1
    screenset cs,-(cs-1)
    cs=-(cs-1)
loop until multikey(1)
Logged

axipher
Ancient Guru
****
Posts: 544



« Reply #32 on: December 18, 2005, 10:12:08 PM »

That's, maybe it's not obscure, but it's damn sweet and fun to play.
Logged
Deleter
Na_th_an
*****
Posts: 1292



WWW
« Reply #33 on: December 21, 2005, 07:45:11 PM »

so are you actually going to judge or...?
Logged

axipher
Ancient Guru
****
Posts: 544



« Reply #34 on: December 21, 2005, 11:18:24 PM »

I guess so.  Well I think that one takes the cake so far for best version, and the bouncy = ( is very smart and effective, really confuses the reader, but the "paddle" is damn sweet, me and some friends got to 800 today at school on about 7 difficulty without dieing, we all had fun, that's a;; we do in drafting and I have an 84...  If only life were that easy.
Logged
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #35 on: December 22, 2005, 12:32:16 AM »

Quote from: "Deleter"
so are you actually going to judge or...?


Quote from: "Zack"
Yetifoot wins.



Axipher, he wasnt speaking to you. The competition starter does the judging.
Logged
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!