Category:Examples
From SDL.NET
|
Looking at examples are an excellent way to learn about the SDL.NET library. This page provides information about the official examples as well as a master list of external examples.
Audio Example
AudioExample.jpg
Keyboard Controls
- Space: Fadeout music
- Up Arrow: Increase volume
- Down Arrow: Decrease volume
- Right Arrow: Pan music right
- Left Arrow: Pan music left
- Escape: Quit example
Mouse Controls
- Primary Button: Pan music left
- Secondary Button: Pan music right
Code
AudioExample.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/AudioExample.cs?view=markup)
See Also
Bomb Run
BombRun.jpg
BombRun is a simple shooting game where the player moves on the bottom of the screen and shoots at the bombs falling down.
Keyboard Controls
- Right and Left Arrows move the player from side to side
- Up Arrow makes player "jump"
- Space shoots a bullet.
- Escape quits the demo
Code
- BombRun.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/BombRun.cs?view=markup)
- Bomb.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/Bomb.cs?view=markup)
- Bullet.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/Bullet.cs?view=markup)
- Player.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/Player.cs?view=markup)
- FireEventArgs.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/FireEventArgs.cs?view=markup)
Bounce Sprites
BounceSpritesExample.jpg
Code
- BounceSprites.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/BounceSprites.cs?view=markup)
- BounceSprite.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/BounceSprite.cs?view=markup)
CD Player
CDPlayer.jpg
The CDPlayer example demonstrates the CD capability of SDL.NET. It can play, pause select tracks and eject the CD. It also features SDL.NET Winforms integration by using a Sprite moving on the form. You can use the mouse to grab the bouncing ball and move it around.
Code
- CDPlayerApp.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/CDPlayer/CDPlayerApp.cs?view=markup)
- BounceSprite.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/CDPlayer/BounceSprite.cs?view=markup)
See Also
Gears
Gears.png
The Gears Example uses the power of OpenGL through Tao.OpenGL and SDL.NET to display rotating gears.
Code
Gears.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/Gears.cs?view=markup)
Credits
- Conversion to GLUT by Mark J. Kilgard
- Conversion to C# by Lux, Using Tao.OpenGL & SDL.NET - 2003/10/15
- Revised to use SDL.NET 2.x by David Hudson 2004-11-04
- Revised to use SDL.NET 3.x by David Hudson 2005-02-04
Gtk Window Example
The following is an example of using SDL.NET with a GTK# window. Click on the "Close" button to close the window.
GtkWindow.png
The Code
GtkWindow.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/GtkWindow.cs?view=markup)
GtkWindowExample.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/GtkWindowExample.cs?view=markup)
See Also
- GTK# Website (http://mono-project.com/GtkSharp)
Gtk Sprite Example
The following is an example of using SDL.NET sprites with a GTK# window. You can use the mouse to click on a circle and drag it around.
GtkSpriteExample.png
The Code
GtkSprite.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/GtkSprite.cs?view=markup)
GtkSpriteExample.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/GtkSpriteExample.cs?view=markup)
See Also
- Mono GTK# Website (http://mono-project.com/GtkSharp)
Hello World Example
The following is an extremely simple example of creating a SDL.NET window for the first time
HelloWorld.jpg
The Code
HelloWorld.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/HelloWorld.cs?view=markup)
See Also
Hero Example
The following is an example of how to use the Animated Sprite class. When run, you will see a little character on the screen which you can then move around by using the arrow keys.
HeroExample.png
The Hero
This is the image that we'll be using as our hero:
Missing image
Hero.png
Image:Hero.png
The Code
HeroExample.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/HeroExample.cs?view=markup)
See Also
Particles Example
ParticlesExample.jpg
Keyboard Controls
Space bar: create a particle explosion.
Mouse Controls
Moving the mouse will attract the ball and particle. The particle emitter will move as well.
Code
- View Source (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/ParticlesExample.cs?view=markup)
Rectangles Examples
Rectangles.png
This example shows use of drawing primitives on a surface as well as basic input control. When you start the application, it draws random rectangles on the screen. When you press escape, it closes the example.
Other Primitives
SDL.NET uses SDL_gfx for drawing primitives on surfaces. It has the capabilities of drawing all sorts of primitive objects like circles, polygons, lines, etc, all with alpha transparency.
Code
The source can be found here (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/Rectangles.cs?view=markup)
See Also
SharpNes
SharpNesScreenshot.png
Tetris.png
Elite.png
BombSweeper.png
This demo is a port of the SharpNes Nintendo entertainment system (NES) emulator to SDL.NET. SharpNes was written by Jonathan Turner and ported to SDL.NET by David Hudson
Keyboard Controls
Use arrow keys to move.
Press 'Z' for button A
Press 'X' for button B
Press 'A' for Select
Press 'S' for Start
Code
SharpNes Source (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SharpNes)
See Also
- SharpNes Website (http://jturner.tapetrade.net/sharpnes/)
Simple Game
SimpleGame.jpg
Keyboard Controls
Use arrow keys to move red ball
Code
SimpleGame Source (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SimpleGame)
Sprite Collection Sorting
SpriteCollectionSort.jpg
Code
SpriteCollectionSort.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/SpriteCollectionSort.cs?view=markup)
Snow Demo
SnowDemo.jpg
Code
SnowDemo.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/SnowDemo.cs?view=markup)
Snowflake.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/Snowflake.cs?view=markup)
TextItem.cs (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/SmallDemos/TextItem.cs?view=markup)
Triad
Triad.jpg
Keyboard Controls
- Right and left arrows: move the block to the right nad left.
- Down Arrow: move block down
Code
Triad Source (http://cs-sdl.svn.sourceforge.net/viewvc/cs-sdl/trunk/SdlDotNet/examples/SdlDotNetExamples/Triad)
Official Examples
The following are the official examples that are packed with the library and are described in more detail.
Subcategories
There is 1 subcategory to this category.E
Articles in category "Examples"
There are 12 articles in this category.
IMN |
PRS |
S cont. |

