<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Error' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Error' posted on the 'Console programming' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 08:57:11 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 08:57:11 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Error</title>
      <link>http://www.programmersheaven.com/mb/Console/386990/386990/error/</link>
      <description>I'M getting the following error when I try to compile this code: "'Function' can only appear in main program."&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;;Draw a ship which can be moved and killed

Graphics 400, 300

;CONSTANTS
Const STARTHITPOINTS = 3
Const SHIP$ = "&amp;lt;-*-&amp;gt;"
Const ESCKEY = 1, SPACEBAR = 57, UPKEY = 200, LEFTKEY = 203, DOWNKEY = 208, RIGHTKEY = 205
Const STARTX = 200, STARTY = 150

;TYPES
Type Ship
		Field x, y
		Field hitpoints
		Field shipstring$
End Type


;INITIALIZATION SECTION
Global cont = 1
Global player.ship = New ship
player\x = STARTX
player\y = STARTY
player\hitpoints = STARTHITPOINTS
player\shipstring = SHIP$


;Game loop
While cont = 1
		Cls
		Text player\x, player\y, player\shipstring$
		
		TestInput()
		DrawHUD()
Wend
;End of loop


;FUNCTION TextInput() - changes the direction or hit points of the player
Function TestInput()

;If player presses left, move him left.
If KeyHit(LEFTKEY)
	player\x = player\x - 3
	If player\x &amp;lt;= 0
			player\x = 10


	EndIf
EndIf

;If player presses right, move him right.
If KeyHit(RIGHTKEY)
		player\x = player\x + 3

If player\x &amp;gt;= 385
		player\x = 380
	EndIf
EndIf

;If player presses up, move him up
If KeyHit(UPKEY)
		
		player\y = playery - 3
		If player\y &amp;lt;= 0
			player\y = 10
	EndIf
EndIf

;If player presses down, move him down.
If KeyHit(DOWNKEY)

		player\y = player\y + 3
		If player\y &amp;gt;= 285
			player\y = 280
	EndIf
EndIf

;If player presses spacebar, remove a hit point

If KeyHit(SPACEBAR)

		player\hitpoints = player\hitpoints - 1
		If player\hitpoints &amp;lt;= 0
				cont = 0
		EndIf
EndIf

;If player presses Esc, set cont to 0, and exit the game
If KeyHit(ESCKEY)
	cont = 0
EndIf


;Function DrawHUD() - draws the user's info in top Right of the screen
Function DrawHUD()
		Text 260, 10, "X position: " + player\x
		Text 260, 20, "Y positoin: " + player\y
		Text 260, 30, "Hitpoints: " + player\hitpoints
End Function&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/Console/386990/386990/error/</guid>
      <pubDate>Sun, 08 Mar 2009 18:09:33 -0700</pubDate>
      <category>Console programming</category>
    </item>
  </channel>
</rss>