GPWiki.org
GPWiki.org
It is currently Wed May 22, 2013 4:32 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: End-of-line help
PostPosted: Wed Dec 26, 2007 12:07 am 
Hi

I just started learning to program. I'm using a book called "3D Game Programming for Teens". The book gave me a code to put into a software called Blitz3D. I put everything in but every time I click run it tells me "Expecting end-of-line". What do I have to do?


Top
  
 
 Post subject:
PostPosted: Wed Dec 26, 2007 9:28 pm 
Octogenarian

Joined: Thu Nov 01, 2007 7:44 pm
Posts: 88
Location: earth MW(milky way)
put a empty line at the end of your code?
i have absoloutly no idea exept that i know that compilers sometimes complain for that reason

_________________
"Education is what remains after one has forgotten everything he learned in school."
"If you can't explain it simply, you don't understand it well enough."
"Anyone who has never made a mistake has never tried anything new."
~Albert Einstein


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 27, 2007 6:35 pm 
Here's the code im using:
Code:
; Jumping Cone
;_______________

camdistance=10
Graphics3D 640,480
SetBuffer BackBuffer()

; creating the types
type_player=1
type_ground=2

; create camera
camera=CreateCamera()
RotateEntity camera, 45,0,0

; creating a light
light=CreateLight()

;creating a plane and texture
grid_tex=CreateTexture( 32,32,8 )
ScaleTexture grid_tex,10,10
SetBuffer TextureBuffer(  grid_tex )
Color 0,0,64:Rect 0,0,32,32
Color 0,0,225:Rect 0,0,32,32,False
SetBuffer BackBuffer()
grid_plane=CreatePlane()
EntityTexture grid_plane,grid_tex
EntityBlend grid_plane,1
EntityAlpha grid_plane,.6
EntityFX grid_plane,1
EntityType grid_plane,type_ground

; creating a mirror
CreateMirror()

; creating a cone
cone=CreateCone(64)
EntityType cone,type_player
PositionEntity cone,0,1,5
ScaleEntity cone,0.4,0.4,0.4
EntityRadius cone, 0.5
Texture=CreateTexture(16,16):SetBuffer TextureBuffer(texture)
ClsColor 256,6,56
Cls
Color 12,126,256
Rect 0,0,8,8,1
Rect 8,8,8,8,1
ScaleTexture texture,.2,.2
EntityTexture cone,texture

;the following cone makes the program run

While Not KeyDown( 1 )
Y#=0

If KeyDown( 208 )=True Then velocity#=velocity#-0.001
If KeyDown( 200 )=True Then velocity#=velocity#+0.001
If KeyDown( 31 ) Then velocity#=0
If KeyDown( 31 ) Then xvelocity#=0
If KeyDown( 203 )=True Then xvelocity#=xvelocity#-0.001
If KeyDown( 205 )=True Then xvelocity#=xvelocity#=0.001
If KeyDown( 57 )True Then y#=y#+5

MoveEntity cone,xvelocity#,y#,velocity#
TranslateEntity cone,0,-0.1,0
PositionEntity camera,EntityX(cone),0,EntityZ(cone)
MoveEntity camera,0,0,-5
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2

UpdateWorld

RenderWorld
Flip

Wend

End


Top
  
 
 Post subject:
PostPosted: Sat Dec 29, 2007 2:48 am 
I figured out my mistake.
Thanks for trying to help.


Top
  
 
 Post subject: Re: End-of-line help
PostPosted: Wed May 15, 2013 9:50 pm 
Novice

Joined: Wed May 15, 2013 9:47 pm
Posts: 5
Quote:
I figured out my mistake.
Thanks for trying to help.


What exactly did you find out? I'm using the same book, and I can't figure out what I did wrong :\ . Could you paste the revised code and tell me what you did? Thanks!


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Wed May 15, 2013 10:07 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6711
Location: Oxford, Englandshire
Have you got an empty line after your final statement? It was suggested above, and I've seen compilers complain about it before.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Thu May 16, 2013 12:03 am 
Novice

Joined: Wed May 15, 2013 9:47 pm
Posts: 5
Codehead wrote:
Have you got an empty line after your final statement? It was suggested above, and I've seen compilers complain about it before.


I put an empty line but it still doesn't work :(


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Thu May 16, 2013 6:51 am 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6711
Location: Oxford, Englandshire
Is there any more information in the error message? A line number?

Can you copy and paste the error here or type it out exactly?

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Thu May 16, 2013 6:38 pm 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 277
Location: Here (where else?)
Code:
If KeyDown( 57 )True Then y#=y#+5
looks suspicious while glancing through the code, other lines either have "= True" or nothing

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Sat May 18, 2013 1:19 pm 
Novice

Joined: Wed May 15, 2013 9:47 pm
Posts: 5
Codehead wrote:
Is there any more information in the error message? A line number?

Can you copy and paste the error here or type it out exactly?


It says "Expecting end of file" or "end of line"


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Sat May 18, 2013 4:52 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6711
Location: Oxford, Englandshire
Hmmm. Google suggests a syntax error. Have you checked Alberth's suggestion above?

You can comment out that line like this:

Code:
; If KeyDown( 57 )True Then y#=y#+5


If commenting out that line doesn't cure it, you could try commenting out chunks of code to try and narrow down the problem.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Sun May 19, 2013 2:41 pm 
Novice

Joined: Wed May 15, 2013 9:47 pm
Posts: 5
Codehead wrote:
Hmmm. Google suggests a syntax error. Have you checked Alberth's suggestion above?

You can comment out that line like this:

Code:
; If KeyDown( 57 )True Then y#=y#+5


If commenting out that line doesn't cure it, you could try commenting out chunks of code to try and narrow down the problem.


I'll try that when I get home. Thanks!


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Sun May 19, 2013 5:29 pm 
Novice

Joined: Wed May 15, 2013 9:47 pm
Posts: 5
I tried adding the comment for that specific line, but it didn't work. Here's the code without the comment:

Code:
; 1st project, Jumping Cone

;------------------------------

camdistance=10
Graphics3D 1920,1080
SetBuffer BackBuffer()

;types
type_player=1
type_ground=2

;camera
camera=CreateCamera()
RotateEntity camera, 45,0,0

;light
light=CreateLight()

;plane/texture
grid_tex=CreateTexture(32,32,8)
ScaleTexture grid_tex,10,10
SetBuffer TextureBuffer (grid_tex)
Color 0,0,64:Rect 0,0,32,32
Color 0,0,255:Rect 0,0,32,32,False
SetBuffer BackBuffer()
grid_plane=CreatePlane()
EntityTexture grid_plane,grid_tex
EntityBlend grid_plane,1
EntityAlpha grid_plane,.6
EntityFX grid_plane,1
EntityType grid_plane,type_ground

;mirror
CreateMirror

;cone
cone=CreateCone(64)
EntityType cone,type_player
PositionEntity cone, 0,1,5
ScaleEntity cone, 0.4,0.4.0.4
EntityRadius cone, 0.5
Texture=CreateTexture(16,16):SetBuffer TextureBuffer(texture)
ClsColor 256,6,256
Cls
Color 12,126,256
Rect 0,0,8,8,1
Rect 8,8,8,8,1
ScaleTexture,.2,.2

;run

While Not KeyDown(1)
y#=0

If KeyDown(208)=True Then velocity#=velocity#-0.001
If KeyDown(200)=True Then velocity#-velocity#+0.001
If KeyDown(31) Then velocity#=0
If KeyDown(31) Then xvelocity#=0
If KeyDown(203)=True Then xvelocity#=xvelocity#-0.001
If KeyDown(205)=True Then xvelocity#=xvelocity#+0.001
If KeyDown(57)=True Then y#=y#+0.5

MoveEntity cone,xvelocity,y,velocity
TranslateEntity cone, 0,-0.1,0
PositionEntity camera, EntityX(cone),0,EntityZ(cone)
MoveEntity camera,0,0,-5
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2

UpdateWorld

RenderWorld
Flip

Wend

End


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Mon May 20, 2013 7:32 am 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 277
Location: Here (where else?)
It seems to me you are trying to make too large steps.
You are doing a sort-of big-bang approach. Type in a few pages of code, and try to run it.
If it works :thumbs
If it fails :\
The problem with the latter is however, that now you have a large blob of text, it is wrong somewhere, but no clue where :(

Unfortunately, I don't know the language you use, nor do I have access to such a programming environment, so I cannot point out where it is wrong.
You'll have to help yourself.

A good strategy to get an understanding of a large problem is to reduce its size.
Make a copy of the current code at some safe place.

Next, throw away everything below ";run" (except possibly the final "End", not sure about what it does).
If this smaller program does not give the error, you know the problem is in the part you just deleted.
If the error is still there, you know it's in the part you still have (technically, there could be two errors, one in the part you still have, and one in the part you just deleted, but let's do one problem at a time).

If the error is still there, you have not deleted enough. Try to delete more, reducing it further.
If the error has gone, you should re-add some lines, and check again whether the error re-appears.
Eventually, you should find a situation where not having a line gives no error, and adding the line causes the error.
Then you know (with a large chance), the error is at that line. Fxing that line is then (hopefully) easy. First fix it in the reduced program. If that works, copy the change into the saved copy (this is why I said to make a copy first).

A few things to keep in mind:
- When you delete parts of the program it will not work anymore (as in, do anything useful). That's ok though, as your only interest is in finding the line with the problem. After fixing, it should work (if there are no other errors in the code).
- The line "While Not KeyDown( 1 )" and the line "Wend" seem to belong to each other, it is probably wise to add or remove these at the same time.

Good hunt!

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
 Post subject: Re: End-of-line help
PostPosted: Mon May 20, 2013 11:16 am 
Rookie

Joined: Sun Apr 21, 2013 8:40 am
Posts: 4
Oh Blitz3d - my first language! I don't have it installed on this PC anymore so I can't test what I'd advise you - but try this:
Spoiler: show
Code:
; 1st project, Jumping Cone

;------------------------------

Local camdistance=10
Graphics3D 1024, 768, 0, 1
SetBuffer BackBuffer()

;types
Local type_player=1
Local type_ground=2

;camera
camera=CreateCamera()
RotateEntity camera, 45,0,0

;light
light=CreateLight()

;plane/texture
grid_tex=CreateTexture(32,32,8)
ScaleTexture grid_tex,10,10
SetBuffer TextureBuffer (grid_tex)
Color 0,0,64:Rect 0,0,32,32
Color 0,0,255:Rect 0,0,32,32,False
SetBuffer BackBuffer()
grid_plane=CreatePlane()
EntityTexture grid_plane,grid_tex
EntityBlend grid_plane,1
EntityAlpha grid_plane,.6
EntityFX grid_plane,1
EntityType grid_plane,type_ground

;mirror
mirror = CreateMirror()

;cone
cone=CreateCone(64)
EntityType cone,type_player
PositionEntity cone, 0, 1, 5
ScaleEntity cone, .4,.4,.4
EntityRadius cone, 0.5
Texture=CreateTexture(16,16):SetBuffer TextureBuffer(texture)
ClsColor 256,6,256
Cls
Color 12,126,256
Rect 0,0,8,8,1
Rect 8,8,8,8,1
ScaleTexture Texture,.2,.2
SetBuffer BackBuffer()
;run

Local y# = 0
Local velocity# = 0
Local xvelocity# = 0
While Not KeyDown(1)
y=0

If KeyDown(208) Then velocity=velocity-0.001
If KeyDown(200) Then velocity=velocity+0.001
If KeyDown(31) Then
velocity=0
xvelocity = 0
EndIf
If KeyDown(203) Then xvelocity=xvelocity-0.001
If KeyDown(205) Then xvelocity=xvelocity+0.001
If KeyDown(57) Then y=y+0.5

MoveEntity cone,xvelocity,y,velocity
TranslateEntity cone, 0,-0.1,0
PositionEntity camera, EntityX(cone),0,EntityZ(cone)-5
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2

UpdateWorld()

RenderWorld()
Flip

Wend

End


I don't see any really "good result", so I decided to write a little something(installed blitz3d):
Spoiler: show
Code:
; 1st project, Jumping Cone

;------------------------------
Local random_seed = 8
SeedRnd random_seed

Local screen_width = 1024
Local screen_height = 768

Graphics3D screen_width, screen_height, 0, 1
SetBuffer BackBuffer()

;types
Local type_player=1
Local type_ground=2

Local cam_distance# = 7

;player init
cone=CreateCone(8)
EntityType cone,type_player
PositionEntity cone, 0, 5, 0
ScaleEntity cone, .4,.4,.4
EntityRadius cone, 0.5

piv = CreatePivot(cone)


Local fog_near = 10
Local fog_far = 50
camera = CreateCamera(piv)
CameraFogMode camera, 1
CameraFogRange camera, fog_near, fog_far
CameraFogColor camera, 0, 0, 0
PositionEntity camera, EntityX(cone), EntityY(cone)+.2, EntityZ(cone)-cam_distance


;world init
plane = CreatePlane()
EntityType plane, type_ground
EntityColor plane, 100, 100, 200
EntityAlpha plane,.5

mirror = CreateMirror()

Local elements_num = 50
Local counter = 0
Local element_type = 0
Local element = 0
;wrap:
Local wrap_min_x = -64
Local wrap_min_z = -64
Local wrap_max_x = 64
Local wrap_max_z = 64

For counter = 1 To elements_num

element_type = Rand(1,4)
Select element_type
Case 1
element = CreateCube()
Case 2
element = CreateCylinder()
Case 3
element = CreateCone()
Case 4
element = CreateSphere()
End Select

PositionEntity element, Rnd(wrap_min_x+10, wrap_max_z-10), Rnd(2, 5), Rnd(wrap_min_z+10, wrap_max_z-10)
EntityColor element, Rand(0,255), Rand(0, 255), Rand(0, 255)
ScaleEntity element, Rnd(.5, 2), Rnd(.5, 2), Rnd(.5, 2)
EntityType element, type_ground

Next




pivot = CreatePivot(); the point around which the camera will revolve


;light
light=CreateLight(1, pivot)
MoveEntity light,0,0, -20


;Player:
Local player = cone
Local speed_z# = .3
Local strafe# = .2
Local air_speed_z# = speed_z/2
Local speed_x# = .5
Local jump_strength# = .8
Local y_change# = 0
Local touch_ground = 0

;World:
Local gravity# = .02
Local light_revol# = .5
Local wireframe_state = 0



Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2
PointEntity camera, player
While Not KeyDown(1)


;Input
If EntityCollided(player, type_ground) Then
touch_ground = 1
y_change = 0
EndIf

If touch_ground Then

If KeyDown(31) Then
MoveEntity player, 0, 0, -speed_z
EndIf

If KeyDown(17) Then
MoveEntity player, 0, 0, speed_z
EndIf

If KeyDown(30) Then
MoveEntity player, -strafe, 0, 0
EndIf

If KeyDown(32) Then
MoveEntity player, strafe, 0, 0
EndIf

If KeyHit(57) Then
y_change = jump_strength
touch_ground = 0
EndIf

Else

y_change = y_change - gravity
MoveEntity player,0 , y_change, 0

If KeyDown(31) Then
MoveEntity player, 0, 0, -air_speed_z
EndIf

If KeyDown(17) Then
MoveEntity player, 0, 0, air_speed_z
EndIf


EndIf

TurnEntity player, 0, -speed_x*MouseXSpeed(), 0
TurnEntity piv, speed_x*MouseYSpeed(), 0, 0
MoveMouse screen_width/2, screen_height/2
TurnEntity pivot, light_revol, 0, 0
PointEntity light, pivot


If KeyHit(28) Then
wireframe_state = 1-wireframe_state
WireFrame wireframe_state
EndIf


;World wrap

If EntityX(player) > wrap_max_x Then
PositionEntity player, wrap_min_x, EntityY(player), EntityZ(player)
EndIf

If EntityX(player) < wrap_min_x Then
PositionEntity player, wrap_max_x, EntityY(player), EntityZ(player)
EndIf

If EntityZ(player) < wrap_min_z Then
PositionEntity player, EntityX(player), EntityY(player), wrap_max_z
EndIf

If EntityZ(player) > wrap_max_z Then
PositionEntity player, EntityX(player), EntityY(player), wrap_min_z
EndIf


UpdateWorld()

touch_ground = 0

RenderWorld()

Text 0,0, "Player X: " + EntityX(player) + ", Y: " + EntityY(player) + ", Z: " + EntityZ(player)
Flip

Wend

End


Btw here's an image - try the code and tell me what you think about it, I haven't coded in B3D for ages, so I'd be happy to see what you make out of it.
Spoiler: show
Image


Btw here's a nice IDE for B3d too:
http://www.fungamesfactory.com/index.html

Btw the end of line error is usually when you forget a comma, or some parameter for a function


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group