|
Post by Darkjester on Sept 14, 2008 12:40:19 GMT -5
I was sic of nobody noing how to do line stipple so i decided to do one Glclear(Gl_Color_Buffer_Bit)
Glenable(Gl_Line_stipple)
GlLineStipple(1, 1) GlLineWidth(6)
Gltranslatef(-0.3,0,-6)
Glbegin(Gl_line_loop) Glcolor3f(1,0,0) GlVertex2f(0,1) Glcolor3f(0,1,0) Glvertex2f(-1,-1) Glcolor3f(0,1,1) Glvertex2f(1,-1) Glend() GlDisable(Gl_line_Stipple) GllineWidth(1) Glbegin(Gl_line_loop) Glcolor3f(1,0,0) GlVertex2f(0,1) Glcolor3f(0,1,0) Glvertex2f(-1,-1) Glcolor3f(0,1,1) Glvertex2f(1,-1) Glend() GlScalef(0.9,0.9,0.9) Glbegin(Gl_Triangles) Glcolor3f(1,0,0) GlVertex2f(0,1) Glcolor3f(0,1,0) Glvertex2f(-1,-1) Glcolor3f(0,1,1) Glvertex2f(1,-1) Glend() Swapbuffers()
|
|
|
Post by Adam on Sept 14, 2008 21:18:26 GMT -5
ok, gravitation towards each other with 2 variables Const Gravity# = 0.1 'Gravitational force of the mouse Const Erode# = 0.001 'Erosion of movement (Like friction) Const MBalls = 10
Dim I, A
TextMode(Text_Buffered)
For I= 0 to MBalls - 1 NewSprite(LoadTexture("Data/Ball.png")) SprSetPos(Rnd()% 640, Rnd()% 480) SprSetSize(10,10) Next
Do While SyncTimer(25) For I = 0 To MBalls - 1 For A = 0 To MBalls - 1 BindSprite(I+1) IF Not A = I Then IF SprX() > SprX(1+A) OR SprX() > SpriteAreaWidth() Then SprSetXVel(SprXVel()-Gravity#) ElseIF SprX() < SprX(1+A) Then SprsetXVel(SprXVel()+Gravity#) Endif IF sprY() > SprY(1+(A)) Then SprsetYVel(SprYVel()-Gravity#) ElseIF sprY() < SprY(1+(A)) Then SprsetYVel(SprYVel()+Gravity#) Endif
IF SprXVel() < 0 Then SprSetXVel(SprXVel()+Erode#) ElseIf SprXVel() > 0 Then SprSetXVel(SprXVel()-Erode#) Endif IF SprYVel() < 0 Then SprSetYVel(SprYVel()+Erode#) ElseIf SprYVel() > 0 Then SprSetYVel(SprYVel()-Erode#) Endif Endif Next Next AnimateSprites() DrawText() Wend Loop
|
|
|
Post by chris857 on Jul 4, 2010 15:00:08 GMT -5
Maybe nobody cares, but here's a pong game in six variables with scores. Red uses mouse, blue uses arrow keys.
dim bx# = 0,by# = 0 dim bsx# = 0.51, bsy# = 0.52 dim p1y# = 0,p2y# = 0 glMatrixMode (GL_PROJECTION) glLoadIdentity () glMatrixMode(GL_MODELVIEW) glLoadIdentity() TextMode(TEXT_OVERLAID) while true glClear(GL_COLOR_BUFFER_BIT) glColor3f(1,0,0) glBegin(GL_LINES) glVertex2f(.85,-.1+p1y#) glVertex2f(.85, .1+p1y#) glEnd() glColor3f(0,0,1) glBegin(GL_LINES) glVertex2f(-.85,-.1+p2y#) glVertex2f(-.85, .1+p2y#) glEnd() glColor3f(1,1,1) glBegin(GL_QUADS) glVertex2f(-.01+bx#,-.01+by#) glVertex2f( .01+bx#,-.01+by#) glVertex2f( .01+bx#, .01+by#) glVertex2f(-.01+bx#, .01+by#) glEnd() cls locate 10,0 printr int(bsx#) locate 30,0 printr int(bsy#) while synctimer(20) p1y# = p1y# - mouse_yd() p2y# = p2y# - .05*scanKeyDown(VK_UP) + .05*scanKeyDown(VK_DOWN) if p1y# > 1 then p1y# = 1 endif if p1y# < -1 then p1y# = -1 endif if p2y# > 1 then p2y# = 1 endif if p2y# < -1 then p2y# = -1 endif if bx# < -.9 then bsx# = bsx# + .02 bsy# = bsy# + 1 'red scores bx# = 0 by# = 0 beep() endif if bx# > .9 then bsx# = bsx# - .02 bsx# = bsx# + 1 'blue scores bx# = 0 by# = 0 beep() endif if by# < -.9 then bsy# = bsy# + .02 elseif by# > .9 then bsy# = bsy# -.02 endif if bx# >.83 and bx# <.84 and by# > -.1+p1y# and by# < .1+p1y# then bsx# = bsx# -.01 elseif bx# <-.83 and bx# > -.84 and by# > -.1+p2y# and by# < .1+p2y# then bsx# = bsx# +.01 endif bx# = bx# + bsx# - int(abs(bsx#)) - .5 by# = by# + bsy# - int(abs(bsy#)) - .5 wend DrawText() SwapBuffers() wend
|
|
|
Post by shadow008 on Jul 4, 2010 22:41:14 GMT -5
ppsh!!! six variables....
dim x as string dim i dim temp
x = "111111,222222,333333,444444,555555,666666,777777,888888,999999"
function GetVariable(VarNum)
i = val(mid$(x,(VarNum*7)+1,7)) return i endfunction
function WriteVariable(VarNum,value as string) dim hold$ if len(value) > 6 or len(value) = "" then return 0 else for i = 0 to len(x) if i > VarNum*7+1 and i < VarNum*7+6 then hold$ = hold$ + value+"," + mid$(x,VarNum*7+1,len(x)-(VarNum*7+6)) x = hold$ return 0 elseif i < VarNum*7+1 then hold$ = left$(x,i) endif next endif return 0 endfunction
temp = GetVariable(0) printr temp temp = GetVariable(1) printr temp temp = GetVariable(2) printr temp temp = GetVariable(3) printr temp temp = GetVariable(4) printr temp temp = GetVariable(5) printr temp temp = GetVariable(6) printr temp temp = GetVariable(7) printr temp WriteVariable(5,"000934") temp = GetVariable(5) printr temp temp = GetVariable(6) printr temp WriteVariable(6,lcase$(val(val(GetVariable(7))-val(GetVariable(4))))) temp = GetVariable(6) printr temp drawtext()
do i win?
thats 6 variables including different function variables ;D
|
|
|
Post by Adam on Jul 5, 2010 11:55:33 GMT -5
hmm, not bad. what about kill joy in 6 variables? dim content as string dim mouse as string dim i,j dim blood =2 dim score
textmode(text_buffered)
loadtexstrip("teddy.png") loadtexstrip("splat2.png") for I = 1 to 78 step 2 content = content+ "0" newSprite(3) spraddtexture(4) spraddtexture(5) sprsetanimspeed(.1) sprsetvel(.5,0) sprsetvisible(false) sprsetzorder(10) newsprite(6) spraddtexture(7) spraddtexture(8) spraddtexture(9) spraddtexture(10) spraddtexture(11) sprsetzorder(11) sprsetanimspeed(.5) sprsetpos(-32,240) sprsetanimloop(false) next newsprite(loadtex("S and0082_5_S.jpg")) sprsetzorder(12) sprsetsize(320,240) sprsetpos(160,120) newsprite() copysprite(79) sprsetpos(480,360) newsprite() copysprite(79) sprsetpos(480,120) newsprite() copysprite(79) sprsetpos(160,360) color(255,255,255)
sub createEnemy() if not rnd()% 50 = 1 then return endif for i = 1 to len(content) if mid$(content,i,1) = "0" then content = left$(content,i-1)+"1"+right$(content,len(content)-i) bindsprite(i*2-1) SprSetPos(-16,rnd()%448+16) sprsetzorder(-spry()*0.01) sprsetvisible(true) return endif next end sub
sub killsprite() bindsprite(i*2-1) sprsetvisible(false) content = left$(content,i-1)+"0"+right$(content,len(content)-i) end sub
function getmousex() for j = 4 to len(mouse) if mid$(mouse,j,1) = " " then return val(mid$(mouse,4,j-4)) endif next end function
function getmousey() for j = len(mouse) to 0 step -1 if mid$(mouse,j,1) = " " then return val(mid$(mouse,j+1,len(mouse)-j)) endif next end function
sub checkEnemy() for i = 1 to len(content) if mid$(content,i,1) = 1 then if sprx(i) > 650 then killsprite() elseif mid$(mouse,1,1) = "1" then if getmousex() > sprleft(i*2-1) and getmousex() < sprright(i*2-1) then if getmousey() < sprbottom(i*2-1) and getmousey() > sprtop(i*2-1) then killsprite() score=score+1 bindsprite(blood) blood=blood+2 if blood > 78 then blood = 2 endif sprsetpos(sprpos(i*2-1)) sprsetzorder(-spry()*0.01+1) sprsetframe(0) sprsetangle(rnd()) endif endif endif endif next end sub
sub updatemouse() if mouse_button(0) then if not mid$(mouse,2,1) = "1" then mouse = "11" else mouse = "01" endif else mouse = "00" endif mouse = mouse + " "+(int(mouse_X()*640))+" "+(int(mouse_Y()*480)) end sub
do updatemouse() createEnemy() checkEnemy() cls printr print " Kill Joy in 6 variables!" locate 0,21 print "kills:"+score drawtext() animatesprites() waittimer(15) loop
|
|
|
Post by Darkjester on Jul 5, 2010 23:24:44 GMT -5
I thought this thread died lets bring it back! very cool stuff guys great work adam -darkjester
|
|
|
Post by chris857 on Jul 6, 2010 19:03:59 GMT -5
Unusual Sierpinski Gaskets in only 3 variables.
dim x#, y#, r# glMatrixMode (GL_PROJECTION) glLoadIdentity () glMatrixMode(GL_MODELVIEW) glLoadIdentity() glClear(GL_COLOR_BUFFER_BIT) while true r# = (rnd()%1000)/1000.0 if performancecounter()%5000=0 then glClear(GL_COLOR_BUFFER_BIT) endif if performancecounter()%5000=1000 then glClear(GL_COLOR_BUFFER_BIT) endif if performancecounter()%5000=2000 then glClear(GL_COLOR_BUFFER_BIT) endif if performancecounter()%5000=3000 then glClear(GL_COLOR_BUFFER_BIT) endif if performancecounter()%5000=4000 then glClear(GL_COLOR_BUFFER_BIT) endif
glBegin(GL_POINTS) glColor3f((rnd()%1000)/1000.0,(rnd()%1000)/1000.0,(rnd()%1000)/1000.0) if performancecounter()%5000<1000 then glVertex2f(2*(x#-.5),2*(y#-.5)) endif if performancecounter()%5000>1000 and performancecounter()%5000<2000 then glVertex2f(5*y#*(x#-.5),2*(y#-.5)) endif if performancecounter()%5000>2000 and performancecounter()%5000<3000 then glVertex2f(2*(x#-.5),2*x#*(y#-.5)) endif if performancecounter()%5000>3000 and performancecounter()%5000<4000 then glVertex2f(5*y#*(x#-.5),2*x#*(y#-.5)) endif if performancecounter()%5000>4000 and performancecounter()%5000<5000 then glVertex2f(2/y#*(x#-.5),4*x#*(y#-.5)) endif glEnd() x# = (x# - ((int(r# * 3) * 2) = 2) - .5 * ((int(r# * 3) * 2) = 4)) * .5 y# = (y# - ((int(r# * 3) * 2) = 4)) * .5 if r# < .001 then SwapBuffers() endif wend
This is off topic, but Darkjester, you started this thread in 2008 but it says you joined in 2009?
|
|
|
Post by chris857 on Jul 6, 2010 21:03:51 GMT -5
And a function grapher in 2 variables:
dim f$ dim x as double glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-15,15,-15*.75,15*.75,-1,1) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glDisable(GL_DEPTH_TEST) TextMode(TEXT_OVERLAID)
input "F(x)=",f$ do while true glLoadIdentity() glClear (GL_COLOR_BUFFER_BIT) glBegin(GL_LINE_STRIP) for x = -15 to 15 step .01 exec comp("glVertex2f(x," + f$ + ")") next glEnd()
SwapBuffers() do until ScanKeyDown(VK_F1) loop cls print "F(x)=" clearkeys() input f$ loop
And something in ZERO variables!
glTranslatef(0,-1,0) TextMode(TEXT_OVERLAID) while true glClear(GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT) glBegin(GL_QUADS) glColor3f(1,0,0):glVertex3f(-5,0,-5) glColor3f(0,1,0):glVertex3f( 5,0,-5) glColor3f(0,0,1):glVertex3f( 5,0, 5) glColor3f(1,1,1):glVertex3f(-5,0, 5) glEnd() while synctimer(15) glTranslatef(Scankeydown(VK_RIGHT)*.1-scankeydown(VK_LEFT)*.1,0,Scankeydown(VK_DOWN)*.1-scankeydown(VK_UP)*.1) wend SwapBuffers() wend
And lastly, a method of switching two numbers in only two variables, no temp variable:
dim a = 5 dim b = 38
a = a + b 'a = 5 + 38 (a=43)
b = a - b 'b = 43 - 38 (b=5)
a = a - b 'a = 43 - 5 (a=38)
|
|
|
Post by Supermonkey on Jul 7, 2010 17:03:39 GMT -5
Although some of these are really interesting examples, maybe people should try something that promotes good coding and not terrible coding .
|
|