Code: Select all

`' A simple 3D demo written by AndT`

type xycor

x as double

y as double

end type

type polygon

p1 as xycor

p2 as xycor

p3 as xycor

end type

dim as polygon poly(1 to 2)

sub drawpolygon(byval p1 as xycor,byval p2 as xycor,byval p3 as xycor,byval col as uinteger)

line (p1.x,p1.y)-(p2.x,p2.y),col

line (p2.x,p2.y)-(p3.x,p3.y),col

line (p3.x,p3.y)-(p1.x,p1.y),col

end sub

'Main programm

resx=1024

resy=768

screenres resx,resy,,,1

dim as integer mode,mode2,mode3,mode4,mode5,mode6,mode7,mode8

' FOR FPSVIEW

DIM AS INTEGER frame

DIM AS SINGLE t = TIMER

DIM AS INTEGER FPS

' Main loop

do

' Draw

drawpolygon (Poly(1).p1,Poly(1).p2,Poly(1).p3,15) ' Polygon1

drawpolygon (Poly(2).p1,Poly(1).p2,Poly(1).p3,15) ' Polygon2

sleep 1,1 ' remove this to see the real FPS xD

' Remove

drawpolygon (Poly(1).p1,Poly(1).p2,Poly(1).p3,0) ' Polygon1

drawpolygon (Poly(2).p1,Poly(1).p2,Poly(1).p3,0) ' Polygon2

' Simple Animation Code ;)

if poly(1).p1.x > resx then mode2 = 0

if poly(1).p1.x < 1 then mode2 = 1

if poly(1).p2.y > resy then mode3 = 0

if poly(1).p2.y < 1 then mode3 = 1

if poly(1).p2.x > resx then mode4 = 0

if poly(1).p2.x < 1 then mode4 = 1

if poly(1).p1.y > resy then mode5 = 0

if poly(1).p1.y < 1 then mode5 = 1

if poly(1).p3.x > resx then mode6 = 0

if poly(1).p3.x < 1 then mode6 = 1

if poly(1).p3.y > resy then mode7 = 0

if poly(1).p3.y < 1 then mode7 = 1

if poly(2).p1.x > resx then mode = 0

if poly(2).p1.x < 1 then mode = 1

if poly(2).p1.y > resy then mode8 = 0

if poly(2).p1.y < 1 then mode8 = 1

if mode = 1 then poly(2).p1.x + = 1 else poly(2).p1.x - = 1

if mode2 = 1 then poly(1).p1.x + = 2 else poly(1).p1.x - = 2

if mode3 = 1 then poly(1).p2.y + = 3 else poly(1).p2.y - = 3

if mode4 = 1 then poly(1).p2.x + = 2 else poly(1).p2.x - = 2

if mode5 = 1 then poly(1).p1.y + = 1 else poly(1).p1.y - = 1

if mode6 = 1 then poly(1).p3.x + = 2 else poly(1).p3.x - = 3

if mode7 = 1 then poly(1).p3.y + = 2 else poly(1).p3.y - = 2

if mode8 = 1 then poly(2).p1.y + = 1 else poly(2).p1.y - = 1

' FPSVIEW

frame += 1

IF frame >= 50 THEN

cls

FPS = INT(frame / (TIMER - t))

t = TIMER

frame = 0

locate 2,2

print "FPS : ";FPS

end if

loop until inkey <> ""