Code 1
Rem These variables hold the enemies current position, and his direction
Rem NOTE: That there is no Y position needed as this always remains the same
Dim enemyX = 125
Dim enemyDir$ = "Left"

Rem These variables hold the hero's current position and his direction
Dim herox = 0
Dim heroDir$ = "Right"

Rem This is just a simple variable that holds the key the user pressed
Dim CurrentKey
Code 2
Rem This is called when your application/game is starting up
Rem Here you should give your variables values, or perform any intitialisation tasks
Function Start()
Try
	Rem Load the Hero (Animation)
	Rem 1). Firstly we have to load the file into an image
	Image heroIm, "/Hero.png"
	Rem 2). Now we can convert it into a sprite..but we are doing fancy animation so we use the sprite.animation
	Rem command to split the image into different sprites of the sizes provided.
	Sprite.Animation Hero, heroIm,48, 38
	Rem We want him to look forward to start with and so we use frame 2 as the starting frame.
	Sprite.setframe hero,2

	Rem Load the Enemy (Animation)
	Rem 1). Again, load the enemy image
	Image enemyIm, "/Enemy.png"
	Rem 2). and convert it into a sprite animation. As you can see the enemy is a little bit bigger than the hero.
	Sprite.Animation Enemy, enemyIm,56, 40

	Rem Load the Grass
	Rem 1). The grass is not animated, but still we have to load it as an image
	Image grassIm, "/Grass.png"
	Rem 2). and as we are going to cover the whole of the bottom of the screen we need 2 as 1 isn't wide enough
	Rem Instead of loading two seperately we just use an array.
	Sprite.Array Grass, grassIm, 2
Catch IO
	Rem If the images can't be found then Omega Basic will print out an error and quit your game.
	Print "Error - Cannot load image(s)"
	End
EndCatch
EndTry
EndFunction
Code 3
Action Paint()
			Rem Black Background.
			Rem 1). Set the current pen colour to black
			SetColor 0,0,0
			Rem 2). Draw a filled rectangle the size of the screen
			DRAWFILLEDRECTANGLE 0,0,width(),height()

			Rem Quick Text.
			Rem 1). Set the current pen colour to white
			SetColor 255,255,255
			Rem 2). Draw the *selling text* ;)
			DrawText "A super cool platform demo!", 0, 0
			Rem 3). Draw some simple debug information
			DrawText "Hero is going " + heroDir$, 0, 15

			Rem Draw Grass (this is a sprite array so we have to control both pieces of grass)
			Rem 1). Position the grass just above the bottom of the screen
			Sprite.Position Grass, 0,Height() - 32,0
			Sprite.Position Grass, 128,Height() - 32,1
			Rem 2). Draw the grass ledges
			Sprite.DrawArray Grass,0
			Sprite.DrawArray Grass,1

			Rem Draw Enemy
			Rem Enemy AI is handled by the Loop Action to make him automatically walk around.
			Rem 1). Position the enemy at his x position and then the position calculated by taking the height of
			Rem the enemy and the grass away from the screen height.
			Sprite.Position enemy, enemyX, Height() - 72
			Rem 2). Draw the enemy
			Sprite.Draw enemy

			Rem Draw Our Hero..ahh
			Rem The Hero movement is handled by the KeyPressed Action to allow the user to control him
			Rem 1). Position the enemy at his x position and then the y position calculated by taking the height of
			Rem the hero and the grass away from the height.
			Sprite.Position hero,heroX, Height() - 70
			Rem 2). Draw the hero
			Sprite.Draw hero
		EndAction	
Code 4
Rem We need to get the key that the user pressed and save it for the moment
CurrentKey = GetKey()

Rem The person pressed the right arrow
if CurrentKey = 54 Then
Rem So we tell our game that we are going to be going right
	heroDir$ = "Right" 
EndIf

Rem The person pressed the left arrow
if CurrentKey = 52 Then
	Rem So we tell our game that we are now walking left
	heroDir$ = "Left"
EndIf
Code 5
Rem The hero is looking left and so needs to walk left, but don't let him walk off the screen
if heroDir$ = "Left" Then
	Rem Keep him on screen
	If heroX < 5 Then
		Rem by not letting him go any further left than 5
		heroX = 5
		EndIF
		Rem Keep the (simple) animation in order by looping through 2 frames
		if sprite.frame(hero) = 1 Then
			Rem Ignore the sprites current frame and set it to 0
			Sprite.setFrame hero,0
		Else
			Rem Move to the next frame
			Sprite.next hero
		EndIf
		Rem Now actually move him left by 5 pixels
		heroX = heroX - 5
Rem The hero is looking right, so do everything we did before but apply it to him walking right
Elseif heroDir$ = "Right" Then
	Rem Keep him from walking off the screen
	If heroX > 125 Then
Rem by not letting him go any further right than 125
		heroX = 125
	EndIF
	Rem Again there are 2 frames to use for some simple animation
	if sprite.frame(hero) = 3 Then
		Rem Ignore the sprites current frame and set it to 2
		Sprite.setFrame hero,2
	Else
		Rem Just move to the next frame
		Sprite.next hero
EndIf
	Rem and allow him to move
	heroX = heroX + 5
EndIf
Code 6
Action Loop 1000			
	Rem This code is almost a direct copy of the hero's movement code, the only difference being that the enemy
	Rem is automatically turned when he reaches the end of his walk so he carries on walking.
	if enemyDir$ = "Left" Then
		If enemyX < 50 Then
			enemyX = 50
			enemyDir$ = "Right"
		EndIF
		if sprite.frame(enemy) = 2 Then
			Sprite.setFrame enemy,1
		Else
			Sprite.next enemy
		EndIf
		enemyX = enemyX - 5
Elseif enemyDir$ = "Right" Then
		If enemyX > 125 Then
			enemyX = 125
			enemyDir$ = "Left"
		EndIF
		if sprite.frame(enemy) = 4 Then
			Sprite.setFrame enemy,3
		Else
			Sprite.next enemy
		EndIf
		enemyX = enemyX + 5
	EndIf			
	Rem Update the screen.			
	Repaint()
EndAction