Code archives/Graphics/Take Screenshot
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
| This function allows you to take a screenshot fro withi your game at the press of a key. By Marc van den Dikkenberg http://www.xlsior.org | |||||
Strict
Local ScreenCount:Int=0 ' Number of the current screenshot
Local MaxScreenShot:Int=100 ' Maximum number of screenshots allowed
Graphics 640,480
' Main Loop
While Not KeyDown(Key_Escape)
' Your normal main-loop stuff goes here
' blah blah blah
DrawText (MilliSecs(),Rand(0,1000),Rand(0,700))
' Just draw some text to the screen so we have something to see on the screenshot
Flip
If KeyHit (key_space) Then
' If you hit space, take a screenshot unless you already captured your max.
If ScreenCount:Int<MaxScreenShot:Int Then
Takescreenshot("screenshot",ScreenCount)
' Tthe screenshots will be written to the current folder as: screenshot<number>.jpg
screencount=screencount+1
End If
End If
Wend
Function takescreenshot(basefile:String,Count:Int)
Local picture:TPixmap=GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight())
SavePixmapJPeg(picture,Basefile+Count:Int+".jpg")
End Function |
Comments
| ||
| This is perfect for my game! Thanks for posting the code!! |
Code Archives Forum