
January 13th, 2008, 01:10 PM
|
|
Registered User
|
|
Join Date: Jan 2008
Posts: 2
Time spent in forums: 12 m 50 sec
Reputation Power: 0
|
|
Help, it keeps saying "image does not exist"!
I'm trying to code a game in Blitz Basic and when I tried to run it, it keeps popping up a window saying "image does not exist" and closes.
Can someone please tell me what is wrong with my coding and suggest how I might fix it? Thanks.
Quote: ;expe - RPG World
;set up graphics mode
Graphics 640,480,32
;Set automidhandle to true
AutoMidHandle True
;Set up Backbuffer
SetBuffer BackBuffer()
;IMAGES
;The close and quickly scrolled background
backgroundimageclose = LoadImage("starsfarther.bmp")
;The further and slowly scrolled background
backgroundimagefar = LoadImage("starry.bmp")
;Create scrolling tracker variable
scrolly = 0
;Play the music file and save its channel
backgroundmusic = PlayMusic("ff7theme.mp3")
If Not ChannelPlaying(backgroundmusic)
backgroundmusic = PlayMusic ("ff7theme.mp3")
EndIf
;TYPES
;Player type - holds the actual player
Type player
Field x,y ;the coordinates of the player
Field direction ;the direction that is being faced (one of the DIRECTIONXXX constants)
Field frame ;the frame that should be drawn
Field image ;the image that should be drawn
End Type
;Create player and initialize field
Global player.player = New player
player\x = 320
player\y = 240
player\direction = DIRECTIONLEFT
player\frame = 0
;load the player's image
playerimage = LoadAnimImage("cloudanim.bmp",19,37,0,4)
;CONSTANTS
;The following constants are used for testing key presses
Const ESCKEY = 1, LEFTKEY = 203, UPKEY = 200, RIGHTKEY = 205, DOWNKEY = 208, f10key = 68
;These constants define the direction that is begin faced
Const DIRECTIONLEFT = 1, DIRECTIONUP = 2, DIRECTIONRIGHT = 3, DIRECTIONDOWN = 4
;These constants define how many pixels are moved per frame
Const MOVEX = 5 ;how many pixels moved left/right per frame?
Const MOVEY = 5 ;how many pixels moved up/down per frame?
;Create a scrolling indicator variable
scrolly = 0
;MAIN LOOP
While Not KeyDown(ESCKEY)
;Clear the screen
Cls
;Tile both backgrounds at proper speed
TileImage backgroundimagefar,0,scrolly
TileImage backgroundimageclose,0,scrolly*2
;Increment scrolly
scrolly=scrolly+1
;Reset tracker variable if it gets too large
If scrolly >= ImageHeight(backgroundimageclose) And ImageHeight(backgroundimagefar) Then
scrolly = 0
EndIf
;if user presses f10, take a screenshot
If KeyHit(f10key)
SaveBuffer(FrontBuffer(), "screenshot" + snnum + ".bmp")
snnum = snnum + 1 ;add 1 to the end of the filename
EndIf
;screenshot number, begin at one (it is an integer)
snnum="1"
;If player hits left, move him left, and find the correct direction and frame
If KeyDown(LEFTKEY)
player\x = player\x - MOVEX ;move him left
player\direction = DIRECTIONLEFT ;face him left
player\frame = (player\frame + 1)Mod (1) + (1 * (player\direction)-1)
;find frame
;If player hits up, move him up, and find the correct direction and frame
ElseIf KeyDown(UPKEY)
player\y = player\y - MOVEY ;move him up
player\direction = DIRECTIONUP ;face him up
player\frame = (player\frame + 1)Mod (1) + (1 * (player\direction)-1)
;find frame
;If player hits right, move him right and find the correct direction and frame
ElseIf KeyDown(RIGHTKEY)
player\x = player\x + MOVEX ;move him right
player\direction = DIRECTIONRIGHT ;face him right
player\frame = (player\frame + 1)Mod (1) + (1 * (player\direction)-1)
;find frame
;If player hits down, move him down, and find the correct direction and frame
ElseIf KeyDown(DOWNKEY)
player\y = player\y + MOVEY ;move him down
player\direction = DIRECTIONDOWN ;face him down
player\frame = (player\frame + 1)Mod (1) + (1 * (player\direction)-1)
;find frame
EndIf
;draw the player at correct position and frame
DrawImage player\image,player\x,player\y, player\frame
;Wait a bit
Delay 50
;Flip the front and back buffers
Flip
Wend ;END OF MAIN LOOP
End |
|