; Limit the frame rate of the example to less 100fps or less SetFPS 100 ; Convert the default font to CRF format MakeBitmapFont 1,$ffffff,8 ; ================================ ; Create Water Shape ( WAVE :)) ; ================================ WaterLineShape=NewShape(100,100) WaveHeight=20 Xpos=0 FirstVertex=10 Vertex=FirstVertex For angle=0 To (360*4) Step 5 If Vertex<100 ypos=CosRadius(Baseangle#+angle,WaveHeight) SetShapeVertex Waterlineshape,Vertex,xpos,ypos xpos=xpos+20 Inc vertex EndIf Next lastVertex=Vertex-1 x=GetShapeVertexX(Waterlineshape,FirstVertex) y=GetShapeVertexY(Waterlineshape,FirstVertex) SetShapeVertex Waterlineshape,1,x,y SetShapeVertex Waterlineshape,2,x,1000 SetShapeVertex Waterlineshape,3,xpos,y SetShapeVertex Waterlineshape,4,xpos,1000 EdgeINdex=1 SetShapeEdge WaterlineShape,EdgeINdex,1,2 Inc edgeindex SetShapeEdge WaterlineShape,EdgeINdex,3,4 For Vertex=FirstVertex To lastVertex-1 Inc Edgeindex SetShapeEdge WaterlineShape,EdgeINdex,Vertex,Vertex+1 Next ;========================================================================= ;CReate a Series of Tiles To make the blob Animation blocks. ;========================================================================= Frames=10 BlockSize=64 ; Create the Animated blocks Block_Image=CreateBlocks(BlockSize,frames) ; Create a Map with provision For 2 level maps To be created using it's Blocks Thismap=NewMap(2) ; Import the above Image created into our Map as BLocks MakeMapGFX ThisMap,Block_image,BlockSize,BlockSize,frames+1,RGB(0,0,0) ; Prepare the Block graphics for FX rendering. This Allows Maps to be ; drawn to the images converted to FX format. PrepareFXMap ThisMap ; ========================= ; Create 3 Animations ; ========================= MaxAnims=6 Create_Map_Anims(ThisMap,MAxAnims,Frames) ; CREATE A LEVEL filled with ranomd blocks Constant z=$80000000 Width=100 height=100 MyLevel=NewLevel(ThisMap,Width,height) For ylp=0 To Width For xlp=0 To height PokeLevelTile ThisMap,MyLevel,xlp,ylp,z Or RndRange(1,MaxAnims) Next xlp Next ylp ; SET THIS LEVEL As Transparent + animated.. LevelAnimated ThisMap,MyLevel ;========================================================================= ; Create an FX Image the size of the screen. ;========================================================================= ; This image is used as render target. So we render all our games ; elements to this image, then once were done we drawn it to the real screen. sw=GetScreenWidth() sh=GetScreenHeight() FXScreen=NewImage(sw,sh,2) RenderToImage FXscreen ; create a camera. This camera will attach itself to the current image ; which will be the FX screen CreateCamera 1 CameraCls 1,off ShowControls =Timer()+10000 ;========================================================================= ; MAIN LOOp ;========================================================================= ; Start of Main Loop RenderToScreen Do ; Tell pPB to capture the following drawn items to the scene buffer CaptureToScene ; clear the buffer ClsScene ; draw our map to the scene buffer DrawMap thisMap,MyLevel,0,0 ; draw the camera. This will process the items in the scene buffer ; to the cameras position and render what it can see to the image ; it's attached to. In this case it's attached to the FXscreen ; image DrawCamera 1 ; Redirect drawing to the FX screen image RenderToImage FXScreen ; set the INK mode to Alpha 50% InkMode 1+32 ; set the ink colour to a bluey colour Ink RGB(35,75,125) ; Calc the Y pos of the water WaterY=SinNewValue((sh/4)*3,WaveAngle#,sh/6) WaveAngle#=WrapAngle(WaveAngle#,1) ; draw the wave shape over the map DrawShape WaterLineShape,0,WaterY,2 ; restore the ink mode to normal InkMode 1 ; restore rendering to the screen RenderToScreen ; ================================================ ; Cycle water vertex ; ================================================ Vertex=FirstVertex Xpos=0 vertex=10 For angle=0 To (360*4) Step 10 If Vertex<100 ypos=Cos(baseAngle#+angle)*(WaveHeight*Sin(angle)) ypos=ypos+(Cos((baseAngle#)+(angle*3) )*(WaveHeight/2)) SetShapeVertex Waterlineshape,Vertex,xpos,ypos xpos=xpos+20 Inc vertex EndIf Next sh=GetScreenHeight() x=GetShapeVertexX(Waterlineshape,FirstVertex) y=GetShapeVertexY(Waterlineshape,FirstVertex) SetShapeVertex Waterlineshape,1,x,y SetShapeVertex Waterlineshape,2,x,sh+1 SetShapeVertex Waterlineshape,3,xpos,y SetShapeVertex Waterlineshape,4,xpos,sh+1 Baseangle#=WrapAngle(Baseangle#,1) ; Draw the FX screen image to the actual screen, so we can see it. DrawImage FXscreen,0,0,0 If UpKey() Then MoveCamera 1,0,-5 If DownKey() Then MoveCamera 1,0,5 If RightKey() Then MoveCamera 1,5,0 If LeftKey() Then MoveCamera 1,-5,0 CenterText GetScreenWidth()/2,0,"Rendering Water Effect Over FX Map" Text 0,0,FPS() ; if the demo has been running for less than 10 second then show ; the controls message If ShowControls>Timer() CenterText sw/2,sh/2,"Use Arrows to Scroll Window" EndIf ; updtae the map animations UpdateMapAnims Thismap Sync Loop End ;========================================================================= ; Create the Colour Blocks ;========================================================================= Function CreateBlocks(BlockSize,frames) ; Create a Image to Use to Store out Blob tiles upon Map_Image=NewImage(BlockSize*(Frames+1),BlockSize) ; CReate the set of Blob For lp=0 To frames i=NewImage(BlockSize,BlockSize) c=RndRGB() RenderPhongImage i,GetImageWidth(i)/2,GetImageHeight(i)/2,RGBFade(c,50+((40.0/frames)*lp)),200,255.0/(blocksize-lp) RenderToImage Map_image DrawImage i,blocksize*(lp+1),0,0 DeleteImage i Next RenderToScreen EndFunction Map_image ;========================================================================= ; Create the Mpa Animations ;========================================================================= Function Create_Map_Anims(ThisMap,MAxAnims,Frames) ; Create provision For 3 Animations MapAnimQuantity ThisMap,MaxAnims For Anims=1 To MaxAnims For lp=1 To frames MapAnim_Add_Block ThisMap,Anims,lp Next For lp=frames To 1 Step -1 MapAnim_Add_Block ThisMap,Anims,lp Next MapAnimFrameRate ThisMap,Anims,anims MapAnimType ThisMap,Anims,1 Next Anims EndFunction ;========================================================================= ; Helper function to treat ading map anims like a que ;========================================================================= Function MapAnim_Add_Block(ThisMap,ThisAnim,ThisBlock) If GetMapAnimStatus(ThisMap,ThisAnim)=false CreateMapAnim ThisMap,ThisAnim,1 PokeMapAnim ThisMap,ThisAnim,0,ThisBlock Else size=GetMapAnimSize(thisMap,thisAnim) PokeMapAnim ThisMap,ThisAnim,Size,ThisBlock ResizeMapAnim ThisMap,ThisAnim,Size+1 EndIf EndFunction |