Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Cant figure a thing out!

Author
Message
Framester
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 9th Jan 2013 17:06
I must have looked over this 100 times now and i cant seem to even get my program to run! I have looked through tutorials and still no end is near to me! If anyone could tell me where i have gone wrong, it would be great

Heres my code

`turn window mode on
set window on

`set display mode
set display mode 800, 600, 32
`set sync on
sync on
`set refresh rate to 30
sync rate 30

`hide mouse
hide mouse
`load sprites
load image "ball.png", 1
load image "wall.png", 2
load image "brick.png", 3
load image "quit.png", 4
load image "how to play", 5
load image "play game", 6


`Load sounds
load sound "pacman.mp3", 1
load sound "death.mp3", 2
load sound "hitbrick.mp3", 3


`generate Sprites
sprite 1, xPosition, yPosition, 1
sprite 2, xPosition, yPosition, 2
sprite 3, xPosition, yPosition, 3

`set score to 0
score = 0

`set lives
lives = 3

`play music
play sound 1
sleep 4000

`show score and lives
do
cls
print "Score: " + str$(score)+ "Lives Left:" + str$(lives) + " Level: " + str$(level)

`move left key
if leftkey() = 1
xPosition = xPosition - 5

if xPosition < 0
xPosition = 0
endif
endif

`move right
if rightkey() = 1
xPosition = xPosition + 5

if xPosition > 747
xPosition = 747
endif
endif



`reposition player
xPosition = screen width() / 2
yPosition = screen height() / 2

`check for direction
if direction = 1
bally = bally - 6
endif

if direction = 2
bulletx = bulletx + 6
bullety = bullety - 6
endif

if direction = 3
bulletx = bulletX + 6
endif

if direction = 4
bulletx = bulletx + 6
bullety = bullety + 6
endif

if direction = 5
bullety = bullety + 6
endif

if direction = 6
bulletx = bulletx - 6
bullety = bullety + 6
endif

if direction = 7
bulletx = bulletx - 6
endif

if direction = 8
bulletx = bulletx - 6
bullety = bullety - 6
endif

`move the player
sprite 1, xPosition, yPosition, 10

`when the ball hits
hitbrick = sprite collision(3,0)
sprite 3, brickx, bricky, 1
delete sprite 3
sprite 3, brick1X, brick1Y, 11

`dying
if yposition < 21
play sound 2
sleep 1500

`End game
dec lives
if lives <= 0
end
endif

`refresh the screen
sync
loop

return
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jan 2013 18:04
You can use the [ code ] tag to post source that is easier on the eye

How does the problem manifest itself? Syntax error? Fails to compile? Runs but crashes?

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 9th Jan 2013 23:14 Edited at: 9th Jan 2013 23:15
Why do you even have 'return' at the base?

And you have not described your issue clearly as BatVink also reuests

Quote: "and i cant seem to even get my program to run! "


Tells us nothing...

EDIT

Oh also Framester - Welcome to the forums

Ones and Zeros
17
Years of Service
User Offline
Joined: 7th Jun 2007
Location: Western NY
Posted: 10th Jan 2013 02:36
I've been away from DBP for quite away and was only just starting to learn it then. So this is more of a question then an answer but your code uses a endif, does that require an else? Or should you just use an If Then command?
Framester
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 10th Jan 2013 13:04
Okay, when i press f5, it will come up with a syntax error at the last line, and when i take this out, it will just randomly change to a different line e.g. it says the loop one, so if i delete this just to check, it will say "syntax error. Nesting Error at 144 and 145", but there is nothing at this point.
I have been using end ifs as i have been using if statements...
Any help?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Jan 2013 16:51
Return is meaningless, it is used to return from a subroutine, you have no subroutines.

You can't just delete a loop, it leaves you with an unclosed nest, just as it suggests.

Remove your Return, then review your code for the next error. We can't run your code to help, as it includes media. You should post the formatted code in the [ code ] tags, in doing this you'll probably actually see where the error is from the indentation.

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Jan 2013 17:04 Edited at: 10th Jan 2013 17:06
Do you even code tags?

[[b]code lang=dbp][/b]Code here[[b]/code][/b]

You're missing an endif here:



Also, remove the return statement at the end of your program.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
Framester
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 15th Jan 2013 17:07
Okay, I have fixed all the endifs and added them all. I have removed the return and also indented alot here is my new code


Once run now, my first sound file plays, but also comes up with the error "runtime error at line 45. File does not exist" But at this line I have "sleep 4000" so i really don't understand.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 15th Jan 2013 17:20 Edited at: 15th Jan 2013 17:22
Do something like this and use relative paths or such...



Hope it helps...

EDIT

Woops... missed something in the code and corrected some formatting

Framester
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 16th Jan 2013 15:37
Oh Thanks, i just checked, and the problem was that my images and sounds were in a different folder to my game. Thanks everyone

Login to post a reply

Server time is: 2024-11-23 13:29:06
Your offset time is: 2024-11-23 13:29:06