Jump to content
  • Advertisement
Sign in to follow this  
madoka

Beginnner: What's wrong with my coding??

This topic is 3985 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The scrolling background wouldn't show at all. The only thing that's there is the playerimage which you could move around with the keyboard. (the program i'm using is blitz basic by the way) Here's my coding: ;expe - RPG World ;set up graphics mode Graphics 640,480,32 ;types ;this type defines the coordinate position of the player Type player Field x,y End Type ;68 is the keycode for f10 Const f10key = 68 ;screenshot number, begin at one (it is an integer) snnum="1" ;set up backbuffer and automidhandle SetBuffer BackBuffer() AutoMidHandle True ;Play the music file and save its channel backgroundmusic = PlayMusic("ff7theme.mp3") ;main loop While Not KeyDown(1) If Not ChannelPlaying(backgroundmusic) backgroundmusic = PlayMusic ("ff7theme.mp3") EndIf ;IMAGES ;the close and quickly scrolled background backgroundimageclose = LoadImage("starsfarther.bmp") ;the farther and slowly scrolled background backgroundimagefar = LoadImage("starry.bmp") ;create scrolling tracker variable scrolly=0 ;main loop While Not KeyDown(1) ;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 get too large If scrolly >= ImageHeight(backgroundimageclose) And ImageHeight(backgroundimagefar) Then scrolly=0 EndIf ;load player playerimage = LoadImage("cloud.bmp") ;create the player player.player = New player ;set up beginning values for player player\x = 320 player\y = 240 ;main loop While Not KeyDown(1) ;why user does not press esc ;clear the screen Cls ;if player presses left, move bitmap left If KeyDown (203) player\x = player\x - 1 EndIf ;if player presses left, move bitmap right If KeyDown(205) player\x = player\x + 1 EndIf ;if player presses up, move bitmap up If KeyDown (200) player\y = player\y -1 EndIf ;if player presses down, move bitmap down If KeyDown (208) player\y = player\y + 1 EndIf ;draw the player on screen DrawImage playerimage, player\x,player\y Flip Wend ;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 Wend Flip Wend WaitKey End [Edited by - madoka on January 12, 2008 5:39:59 PM]

Share this post


Link to post
Share on other sites
Advertisement
I'm not familiar with Blitz Basic, but from the looks of things, you haven't actually told the background to render. You have a DrawImage call for the player, but not for the background.

Share this post


Link to post
Share on other sites
When I took out the cls that's bolded below, the background would show except that it wouldn't scroll and when you move the player, it leaves it trail behind it.

Quote:

;expe - RPG World

;set up graphics mode
Graphics 640,480,32

;types
;this type defines the coordinate position of the player
Type player
Field x,y
End Type

;68 is the keycode for f10
Const f10key = 68

;screenshot number, begin at one (it is an integer)
snnum="1"

;set up backbuffer and automidhandle
SetBuffer BackBuffer()
AutoMidHandle True

;Play the music file and save its channel
backgroundmusic = PlayMusic("ff7theme.mp3")
;main loop
While Not KeyDown(1)
If Not ChannelPlaying(backgroundmusic)
backgroundmusic = PlayMusic ("ff7theme.mp3")
EndIf

;IMAGES
;the close and quickly scrolled background
backgroundimageclose = LoadImage("starsfarther.bmp")

;the farther and slowly scrolled background
backgroundimagefar = LoadImage("starry.bmp")

;create scrolling tracker variable
scrolly=0

;main loop
While Not KeyDown(1)

;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 get too large
If scrolly >= ImageHeight(backgroundimageclose) And ImageHeight(backgroundimagefar) Then
scrolly=0
EndIf

;load player
playerimage = LoadImage("cloud.bmp")
;create the player
player.player = New player
;set up beginning values for player
player\x = 320
player\y = 240
;main loop
While Not KeyDown(1) ;why user does not press esc
;clear the screen
Cls

;if player presses left, move bitmap left
If KeyDown (203)
player\x = player\x - 1
EndIf
;if player presses left, move bitmap right
If KeyDown(205)
player\x = player\x + 1
EndIf
;if player presses up, move bitmap up
If KeyDown (200)
player\y = player\y -1
EndIf
;if player presses down, move bitmap down
If KeyDown (208)
player\y = player\y + 1
EndIf
;draw the player on screen
DrawImage playerimage, player\x,player\y

Flip
Wend

;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

Wend
Flip
Wend
WaitKey
End


[Edited by - madoka on January 12, 2008 9:03:05 PM]

Share this post


Link to post
Share on other sites
It looks like you need to take the two tileimage lines above, and replace that bolded cls with them to me.

That will make it draw the background inside the loop, instead of only once before it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!