So many time from the last post, but I need to get more time to post now I write about how to add color or image background to basic Window SDL in any OS, first we need to write the next lines accord to previous post (say more with less words):
import SdlDotNet
import SdlDotNet.Graphics from SdlDotNet
import SdlDotNet.Core from SdlDotNet
import System.Drawing
screen = Video.SetVideoMode(640,480)
Video.WindowCaption = "This is a simplest sample"
screen.Fill(Color.FromArgb(255, 0, 0))
screen.Update()
Events.Quit += Events.QuitApplication
Events.Run()
If you check the code (3 new lines), we need add the System.Drawing assembly to our code to use one specific function (yeah, the Color.From.....), just few lines (only 2) to make one Sdl.Net Window with Color (in my sample code use RED -rgb: 255, 0, 0-, but you can change it that you prefer in rgb notation) and one update to the screen -screen.update()-. Now if I can change the color, how Can I put one image to background Sdl.Net Window?, So simple with Boo really just only test the next code:
import SdlDotNet
import SdlDotNet.Graphics from SdlDotNet
import SdlDotNet.Core from SdlDotNet
screen = Video.SetVideoMode(640,480)
Video.WindowCaption = "This is a simplest sample"
screen.Blit( Surface("background_image.jpg") )
screen.Update()
Events.Quit += Events.QuitApplication
Events.Run()
Note you need one Surface object, who have the name of the image file, this object is parameter to one BLIT method on Screen Object, finally you need Update the screen to works.
PD: I hope this code can be useful for any. If not please Fire this Blog with FLAMES comments. :P
0 comments:
Post a Comment