'Alpha Cube Demo By Shockwave..
'
'
gosub setup

repeat
 setdrawbuf dw
 dw=1-dw
 setdispbuf dw
setrgb 1,150,50,90
setrgb 2,90,150,50
setrgb 3,50,90,150
gtriangle 0,0 to 640,512 to 0,512
gtriangle 0,0 to 640,512 to 640,0
bx=100
by=0
m=0
vo=vo+2
if vo>360 vo=vo-360
for a=1 to 220 step 20
bx=s2(vo+m)
m=m+10
gosub verts
next a


setrgb 1,250,100,10
setrgb 2,10,250,100
setrgb 3,100,10,250
gtriangle 50,50 to 450,450 to 50,450
gtriangle 50,50 to 450,450 to 450,50


gosub rotate
gosub construct
gosub scroll
 gosub clcomp
 gosub cdraw
 gosub logo
setrgb 1,255,255,255
fill rect 0,0 to 640,2
fill rect 0,510 to 640,512

until(1=2)


'---------------------------------------------------------
'               Draw The Shockwave Logo;
'---------------------------------------------------------
label logo
       setrgb 1,230,230,250
       fill rect 530,20 to 580,30
       fill rect 530,20 to 540,50
       fill rect 540,50 to 580,40
       fill rect 580,40 to 570,60
       fill rect 580,60 to 530,70
       fill rect 530,80 to 540,120
       fill rect 570,80 to 580,120
       fill rect 570,95 to 530,105
       fill rect 530,130 to 580,140
       fill rect 530,160 to 580,170
       fill rect 530,130 to 540,170
       fill rect 580,130 to 570,170
       fill rect 530,180 to 580,190
       fill rect 530,210 to 580,220
       fill rect 530,180 to 540,210
       fill rect 530,230 to 540,270
       fill rect 570,230 to 560,250
       fill rect 580,250 to 570,270
       fill rect 530,245 to 580,255
       fill rect 530,280 to 540,320
       fill rect 580,320 to 570,280
       fill rect 550,295 to 560,320
       fill rect 530,320 to 580,310
       fill rect 530,330 to 540,370
       fill rect 580,330 to 570,370
       fill rect 530,330 to 580,340
       fill rect 530,345 to 580,355
       fill rect 530,380 to 540,420
       fill rect 580,380 to 570,420
       fill rect 580,420 to 530,410
       fill rect 530,430 to 540,480
       fill rect 530,430 to 580,440
       fill rect 530,480 to 580,470
       fill rect 530,450 to 570,460
       rect 520,10 to 590,490
return


label verts
setrgb 1,0,0,0
setrgb 2,0,0,0
setrgb 3,255-a,a,a
gtriangle bx,by to bx,512 to bx+64,512
gtriangle bx+128,by to bx+128,512 to bx+64,512
setrgb 2,a,a,255-a
gtriangle bx,by to bx+64,by to bx+64,512
gtriangle bx+128,by to bx+64,by to bx+64,512

return


label scroll
 y=256+220*sn(xr)
 setrgb 1,55,55,255

 text scx+2,y+2,mid$(s$,p,67)
 setrgb 1,250,250,250

 text scx,y,mid$(s$,p,67)
 scx=scx-1
 if scx<-10 then
 scx=scx+10
 p=p+1
 if p>len(s$) p=0
 fi
return

'---------------------------------------------------------
'                     Draw The Object;
'---------------------------------------------------------
label construct
for a=1 to faces
gosub draw
next a
return

'---------------------------------------------------------
'              Draw A Face Of The Object;
'---------------------------------------------------------

label draw
  vx1= tx(f1(a))-tx(f2(a))
  vy1= ty(f1(a))-ty(f2(a))
  vx2= tx(f3(a))-tx(f2(a))
  vy2= ty(f3(a))-ty(f2(a))
  n=  vx1*vy2-vx2*vy1
 if n<0 then
 n=-(n/200)
 setrgb 1,r(a)+n,g(a)+n,b(a)+n
 fill triangle tx(f1(a)),ty(f1(a)) to tx(f2(a)),ty(f2(a)) to tx(f3(a)),ty(f3(a))
 fill triangle tx(f1(a)),ty(f1(a)) to tx(f4(a)),ty(f4(a)) to tx(f3(a)),ty(f3(a))
 if cls(a)=1 then
   setrgb 1,0,0,0
   line tx(f1(a)),ty(f1(a)) to tx(f2(a)),ty(f2(a))
   line tx(f2(a)),ty(f2(a)) to tx(f3(a)),ty(f3(a))
   line tx(f3(a)),ty(f3(a)) to tx(f4(a)),ty(f4(a))
   line tx(f4(a)),ty(f4(a)) to tx(f1(a)),ty(f1(a))
 fi
fi
return


label rotate
'###############################################
'## Rotate And Scale Each Point! Store Result ##
'###############################################
 for a=1 to points
  x1=x(a)
  y1=y(a)
  z1=z(a)
'######################
'## X,Y,Z rotations! ##
'######################
  xx=x1
  yy=y1*cs(xr)+z1*sn(xr)
  zz=z1*cs(xr)-y1*sn(xr)
  y1=yy
  x1=xx*cs(yr)-zz*sn(yr)
  z1=xx*sn(yr)+zz*cs(yr)
  zz=z1
  xx=x1*cs(zr)-y1*sn(zr)
  yy=x1*sn(zr)+y1*cs(zr)
'########################
'## Apply Perspective! ##
'########################
dv=(zz/40)+1
  xx=size*(xx/dv)+250
  yy=size*(yy/dv)+250
  tx(a)=xx
  ty(a)=yy
  tz(a)=zz
 next a
xr=xr+1
yr=yr+2
zr=zr+3
if xr>720 xr=xr-720
if yr>720 yr=yr-720
if zr>720 zr=zr-720
return


'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
'        Compute "Copperlist" and store colours;
'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
label clcomp
   cm=cm+1:rem                              Bar Scrolling;
   if cm>32 cm=cm-32

   b=1
   o=0
for a=1 to 100
bar(a)=ct(b+o+cm)
b=b+2:rem                                        Bar Width
if b>16 then
 b=b-16
 o=o+1:rem                          Next Bar Scroll Offset
 if o>32 o=o-32
fi
next a
return

'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
'                  Draw the "Copperlist";
'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
label cdraw

y=50
for a=1 to 100
   setrgb 1,0,0,bar(a)
   fill rect 50,y to 450,y+1
   fill rect 50,y+2 to 450,y+3

   y=y+4
next a

setrgb 1,255,255,255
rect 50,50 to 450,y
return





label setup
open window 640,512
setrgb 0,155,155,255
s$="                                                                  "
s$=s$+"THIS IS THE ALPHA CUBE DEMO BY SHOCKWAVE (C) 2002 "
s$=s$+"   AS YOU CAN SEE, I'VE BEEN HAVING A LITTLE BIT "
s$=s$+"OF FUN WITH THESE COPPER STYLE EFFECTS..  ON THIER"
s$=s$+" OWN, ALL THESE EFFECTS WOULD HAVE BEEN TYPICAL OF"
s$=s$+" THE AMIGA, HOWEVER IN PRACTICE TO ADD THEM ALL "
s$=s$+"TOGETHER LIKE THIS WOULD HAVE BEEN IMPOSSIBLE.   "
s$=s$+"   ANYWAY, TIME TO GREET A FEW OF MY FRIENDS FROM "
s$=s$+"THE YABASIC FORUMS, THIS IS NOT A FULL LIST AS THE"
s$=s$+" EXECUTION SPEED OF THE DEMO DOESN'T ALLOW FOR ONE"
s$=s$+"...  FIRST UP, PARABELLUM.. YOU HAVE AWAKENED MY "
s$=s$+"MEMORYS OF ALL THOSE OLDSKOOL STYLE DEMOS ON THE "
s$=s$+"AMIGA WHICH I LOVED... THANKS FOR THE INSPIRATION,"
s$=s$+" THIS INTERLACE TECHNIQUE AS YOU KNOW WAS ONE OF "
s$=s$+"YOUR IDEAS, I JUST WANT TO SAY THANKS!    XALTHORN"
s$=s$+".. I'M SORRY THAT OPS2 (IN THIER INFINITE LACK OF "
s$=s$+"WISDOM) HAVE STOPPED PRINTING GEMOCIDE, IT'S AN "
s$=s$+"EXCELLENT GAME THOUGH AND I'M SURE YOU'LL DO IT "
s$=s$+"JUSTICE ON YOUR WEBSITE..     JINX.. THANKS FOR "
s$=s$+"SHARING YOUR EXCELLENT NEW DEMOS WITH US, THE NEW "
s$=s$+"SITE IS A CREDIT TO YOU, WELL DONE!   DEMONEYE.. "
s$=s$+"DO THESE EFFECTS LOOK FAMILIAR TO YOU?    JO.. "
s$=s$+"HOPE YOU MANAGE TO ADD SOME GORE TO YOUR GAME :O) "
s$=s$+"    JIM... THANKS FOR ALL THE LINUX STUFF ON THE "
s$=s$+"FORUM AND ALSO YOUR WORK ON THE EMULATOR WHICH IS "
s$=s$+"TRUELY EXCELLENT..   DOCTOR.. KEEP ON CODING THE "
s$=s$+"GAMES...   SNAKEDOGG... HOPE YOU'RE NOT TOO SNOWED"
s$=s$+" UNDER WITH HOMEWORK :O)   AND TO EVERYONE WHO I "
s$=s$+"HAVE NO SPACE TO MENTION, THANKS FOR CONTRIBUTING "
s$=s$+"TO THE YABASIC FORUMS.. I'LL SEE YOU THERE!    "
s$=s$+"TIME TO WRAP THIS TEXT NOW...   BYE!           "

p=0
scx=0
dim bar(200)
dim ct(128)
for a=1 to 128
 read b
 ct(a)=b
next a
'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
'                  Colour table for bars;
'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo

data 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160
data 160,150,140,130,120,110,100,90,80,70,60,50,40,30,20,10
data 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160
data 160,150,140,130,120,110,100,90,80,70,60,50,40,30,20,10
data 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160
data 160,150,140,130,120,110,100,90,80,70,60,50,40,30,20,10
data 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160
data 160,150,140,130,120,110,100,90,80,70,60,50,40,30,20,10

'---------------------------------------------------------
'            Define the necessary variables;
'---------------------------------------------------------
size=10: rem                       how big do you want it?
dw=1 : Rem                       Double buffering Variable
points=8 : Rem          The amount of points in the object
faces=6 : Rem            The Amount of faces in the object
dim x(points): Rem            Original X co-ordinate store
dim y(points): Rem            Original Y co-ordinate store
dim z(points): Rem            Original Z co-ordinate store
dim tx(points): Rem       Transformed  X co-ordinate store
dim ty(points): Rem        Transformed Y co-ordinate store
dim tz(points): Rem        Transformed Z co-ordinate store
dim f1(faces):rem                   Connections definition
dim f2(faces):rem                   Connections definition
dim f3(faces):rem                   Connections definition
dim f4(faces):rem                   Connections definition
dim r(faces):rem                             Red Component
dim g(faces):rem                           Green Component
dim b(faces):rem                            Blue Component
dim cls(faces):rem                        Cell Shade Face?
'---------------------------------------------------------
'   Define Sine Tables for faster matrix calculations;
'---------------------------------------------------------

 dim cs(720)
 dim sn(720)
 dim s2(720)
 for ang=0 to 720
  cs(ang)=cos(ang*(pi/360))
  sn(ang)=sin(ang*(pi/360))
  s2(ang)=320+(320*sin(ang*(pi/180)))
 next ang
'---------------------------------------------------------
'               Read in the object's points;
'---------------------------------------------------------
for a=1 to points
 read x(a),y(a),z(a)
next a
'---------------------------------------------------------
'         Read In Connections and face parameters;
'---------------------------------------------------------
for a=1 to faces
read f1(a)
read f2(a)
read f3(a)
read f4(a)
read r(a),g(a),b(a),cls(a)
next a
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'   The Object Description As Data!
'   The Data Below Describes A Cube.
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

'Points definition;
'~~~~~~~~~~~~~~~~~~
'Below are the points of the object defined as x,y,z;

data -10,10,10,10,10,10,10,-10,10,-10,-10,10
data -10,10,-10,10,10,-10,10,-10,-10,-10,-10,-10

'Connection definition;
'Below are the faces of the object defined as vertice
'numbers, specified in clockwise order. These are followed
'by r,g,b values for the face and finally cell shaded
'parameter (0)=off (1)=on.

data 1,2,3,4,230,0,0,1
data 5,8,7,6,230,0,0,1
data 6,2,1,5,0,230,0,1
data 8,4,3,7,0,230,0,1
data 2,6,7,3,0,0,230,1
data 8,5,1,4,0,0,230,1

return




