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 / Endwhile out of place

Author
Message
Seannydog
16
Years of Service
User Offline
Joined: 23rd Oct 2007
Location:
Posted: 23rd Oct 2007 15:39
Right my m8 came round 4 a bit the other day and tough me some simple code. Im tryin to learn some more but anyway. I've started making this little spaceship like game. Its quite simple so far ive made it so u can pick 1 of 3 ships and you can move them around the screen and make them shoot a bit.
The only problem is when I run it it says command at line 205 out of place. This command is endwhile and I don't know what to do about it.
If anyone can just take a look at it and just tell me what's wrong with it it would be much a appreciated



REM Project: space fighter
REM Created: 22/10/2007 22:52:08
REM
REM ***** Main Source File *****
REM

set image colorkey 255,0,255

load image "background.bmp",100
sprite 100,0,0,100


create animated sprite 1,"pointer.bmp",3,1,1
create animated sprite 2,"pointer red.bmp",3,1,2
create animated sprite 3,"pointer blue.bmp",3,1,3

sprite 1,screen width()/3,screen height()/2,1
sprite 2,screen width()/2,screen height()/2,1
sprite 3,screen width()/1.5,screen height()/2,1

offset sprite 1,sprite width(1)/2,sprite height(1)/2
offset sprite 2,sprite width(2)/2,sprite height(2)/2
offset sprite 3,sprite width(3)/2,sprite height(3)/2
angle=90
load image "bullet.bmp",4
missile=0


while 1 `========================================================================================================

`so you can pick a fighter to use
if started=0
repeat
if mousex()>=screen width()/3-sprite width(1)/2 and mousex()<=(screen width()/3+sprite width(1)-sprite width(1)/2) AND mousey()>=screen height()/2-sprite height(1)/2 AND mousey()<=(screen height()/2+sprite height(1)-sprite height(1)/2)
set sprite frame 1,2
if mouseclick()=1
started=1
repeat
set sprite frame 1,3
until mouseclick()=0
else
started=0
endif
else
set sprite frame 1,1
started=0
endif

if mousex()>=screen width()/2-sprite width(2)/2 and mousex()<=(screen width()/2+sprite width(2)-sprite width(2)/2) AND mousey()>=screen height()/2-sprite height(2)/2 AND mousey()<=(screen height()/2+sprite height(2)-sprite height(2)/2)
set sprite frame 2,2
if mouseclick()=1
started=2
repeat
set sprite frame 2,3
until mouseclick()=0
else
started=0
endif
else
set sprite frame 2,1
started=0
endif

if mousex()>=screen width()/1.5-sprite width(3)/2 and mousex()<=(screen width()/1.5+sprite width(3)-sprite width(3)/2) AND mousey()>=screen height()/2-sprite height(3)/2 AND mousey()<=(screen height()/2+sprite height(3)-sprite height(3)/2)
set sprite frame 2,2
if mouseclick()=1
started=3
repeat
set sprite frame 2,3
until mouseclick()=0
else
started=0
endif
else
set sprite frame 2,1
started=0
endif

`If you pick fighter one this will happen -----------------------------------------------------------------------------
if started=1
hide sprite 2
hide sprite 3
sprite 1,screen width()/2,screen height()/2,1



if rightkey()=1
angle=angle+2
endif

if leftkey()=1
angle=angle-2
endif

if upkey()=1
move sprite 1,2
endif

if downkey()=1
move sprite 1,-2
endif



`so a bullet fires

if spacekey()=1 then sprite 4,sprite x(1),sprite y(1),4 : rotate sprite 4,angle : missile=1

if missile=1
move sprite 4,2
else
if sprite exist (4)
delete sprite 4
endif
endif

rotate sprite 1,angle

endif


`for ship 2 -----------------------------------------------------------------------------------------------------


if started=2
hide sprite 1
hide sprite 3
sprite 2,screen width()/2,screen height()/2,1



if rightkey()=1
angle=angle+2
endif

if leftkey()=1
angle=angle-2
endif

if upkey()=1
move sprite 2,2
endif

if downkey()=1
move sprite 2,-2
endif


`so a bullet fires

if spacekey()=1 then sprite 4,sprite x(2),sprite y(2),4 : rotate sprite 4,angle : missile=1

if missile=1
move sprite 4,2
else
if sprite exist (4)
delete sprite 4
endif
endif

rotate sprite 2,angle

endif
`--------------------------------------------------------------------------------------------------------------------

if started=3
hide sprite 2
hide sprite 1
sprite 3,screen width()/2,screen height()/2,1



if rightkey()=1
angle=angle+2
endif

if leftkey()=1
angle=angle-2
endif

if upkey()=1
move sprite 3,2
endif

if downkey()=1
move sprite 3,-2
endif


`so a bullet fires

if spacekey()=1 then sprite 4,sprite x(3),sprite y(3),4 : rotate sprite 4,angle : missile=1

if missile=1
move sprite 4,2
else
if sprite exist (4)
delete sprite 4
endif
endif

rotate sprite 3,angle

endif
endwhile

wait key
end

Nothings impossible
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Oct 2007 16:50
We can help, but you need to assist first...

1. Indent your code so that the IF/ENDIF, REPEAT/UNTIL clauses are visible. Putting the code between code tags in the post editor will ensure this is kept when you post. Then, the out of place endwhile will be - hopefully - quite obvious. You will have just missed an ENDIF or something similar.



2. Drop the TXT SPK! This is a forum, and people don't take too kindly to lazy typing. You'll get plenty of help if you post using everyday language!

Seannydog
16
Years of Service
User Offline
Joined: 23rd Oct 2007
Location:
Posted: 23rd Oct 2007 22:04
sorry I was in a hurry at the time and ill put it in code here



that should do it

Nothings impossible
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Oct 2007 05:32
Although you put the code in code boxes, the indentation wasn't correct. Here's your code indented properly using the indentation utility DBA Tidy and you can see where the problem is:



Basically you have a Repeat with no Until and you don't close the first if started=0 If line.

TDK_Man

Seannydog
16
Years of Service
User Offline
Joined: 23rd Oct 2007
Location:
Posted: 26th Oct 2007 14:36
Thanks I managed to fix everything you meationed ive got some more bugs now stuff to do with the started=1 and 2 lines ill post the game when im finished thanks again

These forum signatures are meant to hold 200 characters. 200 characters my as
[url]http://www.freewebs.com/3stylersuk/[/url]

Login to post a reply

Server time is: 2024-09-27 08:25:40
Your offset time is: 2024-09-27 08:25:40