Fun Demos

Do you have something to share with us? A tip for newbies, perhaps? Post it here.
Post Reply
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Fun Demos

Post by peter » Fri Jun 01, 2012 10:16 pm

Hi,

Some new Demos.

Code: Select all

Include "library.cb"

SCREEN 256,256,32,1
FrameLimit 6
font = LoadFont("courier",24)
SetFont font


Global numSteps,n,ax#,ay#,bx#,by#,cx#,cy#,px#,py#
numSteps=10000
ax = 10: cy = 10
ay = ScreenHeight() - 10
bx = ScreenWidth()  - 10
by = ScreenHeight() - 10
cx = ScreenWidth()  / 2
px = ax: py = ay
 
While EscapeKey()=0
ClearScreen(12,230,40)
For n=0 To numSteps
SetPixel(px, py, 0,0,255)
Select Rand(0,2)
       Case 0
          px = (px + ax) / 2.0
          py = (py + ay) / 2.0
       Case 1
          px = (px + bx) / 2.0
          py = (py + by) / 2.0
       Case 2
          px = (px + cx) / 2.0
          py = (py + cy) / 2.0
End Select          
Next n
DrawScreen OFF
Wend
Last edited by peter on Sun Jul 27, 2014 11:55 pm, edited 1 time in total.

peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Re: Fun Demos

Post by peter » Fri Jun 01, 2012 10:17 pm

3D Tree

Code: Select all

Include "library.cb"

SCREEN 640,480,1
font=LoadFont("times",28)
SetFont font

Global b1
b1 = LoadImage("bmp/baum.bmp")
ResizeImage b1,640,480

While EscapeKey()=0
DrawImage b1,0,0,0
For y=0 To 480 Step 20
   For x=0 To 640 step 20
     Color Rand(220,255),10,15      
     Circle x,y,20,0 
   Next x 
Next y

SetText(16,8,"3D TREE ",0,220,0)    
DrawScreen
Wend

peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Re: Fun Demos

Post by peter » Fri Jun 01, 2012 10:19 pm

A curve.

Code: Select all

SCREEN 800, 600, 1
FrameLimit 60
font=LoadFont("arial",24)
SetFont font

Global x1,y1,x2,y2,x3,y3,x4,y4,brick
x1=50:y1=150:x2=100:y2=100:x3=150:y3=100:x4=200:y4=150
brick = LoadImage("bmp/brick.bmp")
ResizeImage brick,800,600

Function Curve(x10,y10,x20,y20,x30,y30,x40,y40)
Dim u#,u2#,u3#,f1#,f2#,f3#,f4#,ax,ay,x,y 
For u=0 To 1.1 Step 1
   u2=u*u
   u3=u*u*u
   f1=-0.5*u3 + 1.0*u2 - 0.5*u
   f2= 1.5*u3 - 2.5*u2 + 1.0
   f3=-1.5*u3 + 2.0*u2 + 0.5*u
   f4= 0.5*u3 - 0.5*u2
   x=x10*f1 + x20*f2 + x30*f3 + x40*f4
   y=y10*f1 + y20*f2 + y30*f3 + y40*f4
   If u >0 Then 
      Color 255,255,255   
      Line ax,ay,x,y
   End If   
   ax = x
   ay = y
Next u
End Function

While EscapeKey()=0 
DrawImage brick,0,0,0
x3 = MouseX()
y3 = MouseY()
Curve(x1,y1, x1,y1, x2,y2, x3,y3)
Curve(x1,y1, x2,y2, x3,y3, x4,y4)
Curve(x2,y2, x3,y3, x4,y4, x4,y4)
Oval( x1-5,y1-5,10,10, 255,0,0)
Oval( x2-5,y2-5,10,10, 255,0,0)
Oval( x3-5,y3-5,10,10, 255,0,0)
Oval( x4-5,y4-5,10,10, 255,0,0)
SetText(300,6,"PRESS ESCAPE KEY",255,255,255)
DrawScreen
Wend

peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Re: Fun Demos

Post by peter » Fri Jun 01, 2012 10:20 pm

Something light.

Code: Select all

include "library.cb"
screen 640,480, 2

Global x, y

While EscapeKey()=0 
For y=0 To ScreenHeight() Step 10
  For x=0 To ScreenWidth() Step 10
    Color 0,120,255
    Box x,y,8,8,0 
    Color Rand(64,255),Rand(64,255),Rand(64,255)     
    Line x,y,240,69
  Next x
Next y  
DrawScreen OFF 
Wend

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest