--- race-maze.py 2004-11-12 17:33:51.000000000 +0200 +++ race.py 2004-11-13 21:48:34.000000000 +0200 @@ -22,6 +22,7 @@ from base import * from complex import * from spread import * +from math import * from classic import bloc9 from __future__ import division @@ -249,6 +250,46 @@ t.add( Box( p1 , p2 ) ) return u , t +def CurvyWireObstacle( level ) : + u , t = Union() , UnionBox() + + length = level * 16 + 48 + + # Controls how accurately the curve is modelled + # Values up to 5 are usable, 5 being the worst quality + # 2 gives 48 objects on level 3 + dividelength = 2 + + wirewidth = 9 / ( level * 3 ) + height = rand( 16 ) - 8 + + t = RemoveSafetyTrack( x = length , z = length ) + + # One could add differend functions and select a random one + def CurvyFunction( pos ) : + return sin( pos / 10 ) * ( trackWidth - 11 ) / 2 + trackWidth / 2 + sin( pos / 4 ) * 4 + + # Offset pos for curve randomness + offset = rand( 5000 ) + + + for i in range( -length , length , dividelength ) : + # Get the rotation angle + hmov = - CurvyFunction( i + offset ) + CurvyFunction( i + dividelength + offset ) + angle = atan( hmov / dividelength ) + degangle = angle * ( 180 / pi ) + # Piece length + plength = sqrt( dividelength ** 2 + hmov ** 2 ) + # Add the piece + # Piece around 0,0,0 for rotation + p1 = Point( - wirewidth / 2 , 0 , - plength / 2 - wirewidth / 5 ) + p2 = Point( wirewidth / 2 , -0.25 , plength / 2 + wirewidth / 5 ) + # Correct 0,0,0 point for piece + p = Point( CurvyFunction( i + dividelength / 2 + offset ) , height , i + dividelength / 2 ) + u.add( Box( p1 , p2 ).rotate( degangle ).at( p ) ) + + return u , t + def EmptyObstacle( level ) : u = Union() t = UnionBox() @@ -1438,6 +1479,7 @@ 'BlockMaze' : ( 4 , False , BlockMazeObstacle ) , 'Buttress' : ( 4 , True , ButtressObstacle ) , 'CatWalk' : ( 4 , True , CatWalkObstacle ) , +'CurvyWire' : ( 10 , False , CurvyWireObstacle ) , 'ClusterBomb' : ( 0 , True , ClusterBombObstacle ) , 'Empty' : ( 0 , False , EmptyObstacle ) , 'GunLadderHurdle' : ( 1 , True , GunLadderHurdleObstacle ) ,