### Author Topic: messing around with dot tunnel code  (Read 778 times)

0 Members and 1 Guest are viewing this topic.

#### Stonemonkey

• Pentium
• Posts: 1307
• Karma: 96
##### messing around with dot tunnel code
« on: November 22, 2016 »
what started out as meant to be some sort of tunnel code but with some modification. No idea what it is.

Code: [Select]
`const pi2=3.141592*2.0type staras single x,y,zas ulong colour(0 to 100),shadeas single radiusas single num_pointsend typetype starfieldas integer num_starsas star ptr star_listas single max_z,min_z,z_speedas ulong colourmap(0 to 255)as ulong colourindex(0 to 100)as ulong colourdelta(0 to 100)end typefunction create_starfield(byval num_stars as integer,_byval radius as single,_byval num_points as single,_byval max_z as single,_byval min_z as single,_byval z_speed as single)as starfield ptrdim as starfield ptr starfield=new starfieldstarfield->star_list=new star[num_stars]for star as integer=0 to num_stars-1starfield->star_list[star].radius=radius+radius*sin(star/num_stars*pi2)starfield->star_list[star].num_points=num_pointsstarfield->star_list[star].z=min_z+((max_z-min_z)/num_stars)*starnextstarfield->max_z=max_zstarfield->min_z=min_zstarfield->z_speed=z_speedstarfield->num_stars=num_starsfor i as integer=0 to 255    dim as ulong red,gre,blu    red=128+127*sin(i/256.0*3.141592*4)    gre=128+127*sin(i/256.0*3.141592*2)    blu=128+127*cos(i/256.0*3.141592*2)    starfield->colourmap(i)=(red shl 16)or(gre shl 8) or blunextfor i as integer=0 to 100    starfield->colourindex(i)=rnd*&hffff    starfield->colourdelta(i)=rnd*&hfffnextreturn starfieldend functionsub process_starfield(byval starfield as starfield ptr)static as single angle=0static as single amplitude_angle=0static as single horizontal_angle=0static as single vertical_angle=0for star_count as integer=0 to starfield->num_stars-1dim as star pointer star=@starfield->star_list[star_count]star->z-=starfield->z_speedstar->x+=(rnd-.5)*10.0star->y+=(rnd-.5)*10.0star->shade=(star->shade*&hfa)shr 8if star->z<starfield->min_z then     for i as integer=0 to star->num_points-1        star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)        'starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff    next    star->shade=&hffffstar->z+=starfield->max_z-starfield->min_zstar->x=(100+300*sin(amplitude_angle))*sin(angle)+300*sin(horizontal_angle)star->y=(100+300*sin(amplitude_angle))*cos(angle)+300*sin(vertical_angle)angle+=0.01amplitude_angle+=.0086horizontal_angle+=.013vertical_angle+=0.0043end ifnext    for i as integer=0 to 100        'star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)        starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff    next    end subsub draw_starfield(byval starfield as starfield pointer)dim as integer w=any,h=anyscreeninfo (w,h)for star_count as integer=0 to starfield->num_stars-1dim as star pointer star=@starfield->star_list[star_count]for p as single=0 to star->num_points-1dim as single x=(w shr 1)+w*(star->x+star->radius*sin(p*pi2/star->num_points))/star->zdim as single y=(h shr 1)-w*(star->y+star->radius*cos(p*pi2/star->num_points))/star->zdim as ulong c=star->shade shr 8dim as ulong col=star->colour(p)pset (x,y),((((col and &hff00ff)*c)and &hff00ff00)or(((col and &hff00)*c)and &hff0000))shr 8nextnextend subsub mainscreenres 640,480,32,2screenset 0,1dim as starfield ptr starfield=create_starfield(300,400,7,2000,10,50)for i as integer=0 to 1000process_starfield(starfield)nextdim as single t=timerwhile inkey<>chr(27)    while t<timer        process_starfield(starfield)        t+=0.02        wenddraw_starfield(starfield)flipclswendend submain`
or

Code: [Select]
`const pi2=3.141592*2.0type staras single x,y,z,rotationas ulong colour(0 to 100),shadeas single radiusas single num_pointsend typetype starfieldas integer num_starsas star ptr star_listas single max_z,min_z,z_speedas ulong colourmap(0 to 255)as ulong colourindex(0 to 100)as ulong colourdelta(0 to 100)end typefunction create_starfield(byval num_stars as integer,_byval radius as single,_byval num_points as single,_byval max_z as single,_byval min_z as single,_byval z_speed as single)as starfield ptrdim as starfield ptr starfield=new starfieldstarfield->star_list=new star[num_stars]for star as integer=0 to num_stars-1starfield->star_list[star].radius=radius+radius*sin(star*pi2/num_stars)starfield->star_list[star].rotation=star*pi2/num_stars*2starfield->star_list[star].num_points=num_pointsstarfield->star_list[star].z=min_z+((max_z-min_z)/num_stars)*starnextstarfield->max_z=max_zstarfield->min_z=min_zstarfield->z_speed=z_speedstarfield->num_stars=num_starsfor i as integer=0 to 255    dim as ulong red,gre,blu    red=128+127*sin(i/256.0*3.141592*4)    gre=128+127*sin(i/256.0*3.141592*2)    blu=128+127*cos(i/256.0*3.141592*2)    starfield->colourmap(i)=(red shl 16)or(gre shl 8) or blunextfor i as integer=0 to 100    starfield->colourindex(i)=rnd*&hffff    starfield->colourdelta(i)=rnd*&hfffnextreturn starfieldend functionsub process_starfield(byval starfield as starfield ptr)static as single angle=0static as single amplitude_angle=0static as single horizontal_angle=0static as single vertical_angle=0for star_count as integer=0 to starfield->num_stars-1dim as star pointer star=@starfield->star_list[star_count]star->z-=starfield->z_speedstar->x+=(rnd-.5)*10.0star->y+=(rnd-.5)*10.0star->shade=(star->shade*&hf0)shr 8if star->z<starfield->min_z then     for i as integer=0 to star->num_points-1        star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)        'starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff    next    star->shade=&hffffstar->z+=starfield->max_z-starfield->min_zstar->x=(100+300*sin(amplitude_angle))*sin(angle)+300*sin(horizontal_angle)star->y=(100+300*sin(amplitude_angle))*cos(angle)+300*sin(vertical_angle)angle+=0.01amplitude_angle+=.0086horizontal_angle+=.013vertical_angle+=0.0043end ifnext    for i as integer=0 to 100        'star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)        starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff    next    end subsub draw_starfield(byval starfield as starfield pointer)dim as integer w=any,h=anyscreeninfo (w,h)for star_count as integer=0 to starfield->num_stars-1dim as star pointer star=@starfield->star_list[star_count]for p as single=0 to star->num_points-1dim as single x=(w shr 1)+w*(star->x+star->radius*sin(star->rotation+p*pi2/star->num_points))/star->zdim as single y=(h shr 1)-w*(star->y+star->radius*cos(star->rotation+p*pi2/star->num_points))/star->zdim as ulong c=star->shade shr 8dim as ulong col=star->colour(p)pset (x,y),((((col and &hff00ff)*c)and &hff00ff00)or(((col and &hff00)*c)and &hff0000))shr 8nextnextend subsub mainscreenres 640,480,32,2screenset 0,1dim as starfield ptr starfield=create_starfield(800,180,12,1000,10,10)for i as integer=0 to 1000process_starfield(starfield)nextdim as single t=timerwhile inkey<>chr(27)    while t<timer        process_starfield(starfield)        t+=0.02        wenddraw_starfield(starfield)flipclswendend submain`
« Last Edit: November 22, 2016 by Stonemonkey »