Problem With expecting ) error...

Blitz3D Forums/Blitz3D Programming/Problem With expecting ) error...

StOrM3(Posted 2004) [#1]
Please, Help me, before I pull all my hair out.. I have been trying to figure out what is wrong, I get the same type of error, when i move the types out to seperate files, someone needs to write a tutorial on how to correctly break the parts of a game out into seperate files, without getting wierd errors. Anyways here is the source, please help me find the logic error.
Thanks

;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; Filename: Alpha_functions.bb
; Written: By - Ken Cornett
; [P.K.E.] - Pain Killa Entertainment(tm) - [P.K.E.]
; Copyright (c) 2004 - All Rights Reserved.
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#Option Explicit
Include "alpha_consts.bb"


  Global tmpcount = 0
  Global cntx, cnty
  Global GX#, GY#
  Global mxspd#, myspd#

Type fruititems
  Field picture
  Field gridx
  Field gridy
  Field time
  Field lives
  Field score
  Field matrix
  Field nextitem
  Field ID
  Field particles
End Type


; Type Variables Declared and Setup 4 Use.
Dim fruit.fruititems(18)
Dim fruitgrid.fruititems(15,15)  
Dim grid(15,15)                 

For tmpcount = 0 To 18
  fruit.fruititems(tmpcount) = New fruititems
Next

For cnty = 0 To 15
  For cntx = 0 To 15
    fruitgrid.fruititems(cntx,cnty) = New fruititems
  Next
Next


Function Setup_Game()
  Graphics 1024, 768		    	; Open graphics display
  SeedRnd MilliSecs ()		
End Function

Function Load_Fruit()
Local filename$

For tmpcount = 0 To 18
  filename$ = "../../media/image" + Str(tmpcount) + ".jpg"
  fruit(tmpcount)\picture = LoadImage(filename$) 
  fruit(tmpcount)\gridx = 1
  fruit(tmpcount)\gridy = 1
  fruit(tmpcount)\time = 0
  fruit(tmpcount)\lives = 0
  fruit(tmpcount)\score = 0
  fruit(tmpcount)\matrix = 0
  fruit(tmpcount)\nextitem = 0
  fruit(tmpcount)\ID = tmpcount
  fruit(tmpcount)\particles = LoadImage("../../media/particle1.jpg")
Next
End Function

Function Read_Grid()
Local x,y						; Grid Positioning x,y
Local tempi						; Hold the currently read number for checking later.
Local gridval

Restore mygrid  ;go back to our data statements.

For y = 0 To 15
  For x = 0 To 15
    Read gridval
    tempi = gridval
	If tempi = 9
	  tempi = Rand(1,8)
	EndIf
	If tempi = 0
	  tempi = Rand(14,18)
	EndIf
	grid(x,y) = tempi
  Next
Next 
End Function

Function Setup_Grid()

Read_Grid()                      

For cnty = 0 To 15
  For cntx = 0 To 15
    fruitgrid(cntx,cnty)\picture = CopyImage(hold(grid(cntx,cnty))\picture)
    fruitgrid(cntx,cnty)\gridx = cntx
    fruitgrid(cntx,cnty)\gridy = cnty
    fruitgrid(cntx,cnty)\time = hold(grid(cntx,cnty))\time 
    fruitgrid(cntx,cnty)\lives = hold(grid(cntx,cnty))\lives 
    fruitgrid(cntx,cnty)\score = hold(grid(cntx,cnty))\score 
    fruitgrid(cntx,cnty)\matrix = hold(grid(cntx,cnty))\matrix 
    fruitgrid(cntx,cnty)\nextitem = hold(grid(cntx,cnty))\nextitem 
    fruitgrid(cntx,cnty)\ID = hold(grid(cntx,cnty))\ID 
    fruitgrid(cntx,cnty)\particles = CopyImage(hold(grid(cntx,cnty))\particles)
  Next
Next
End Function

Function Draw_Fruit()
Local countx, county

  SetBuffer BackBuffer()
  For county = 0 To 15
    For countx = 0 To 15
      DrawImage(fruitgrid(countx,county)\picture,countx * 32, county * 32)
    Next
  Next
End Function

Function Main_Game_Loop()

  Setup_Game()

  Load_Fruit()

  Setup_Grid()

  Draw_Fruit()

  
While Not KeyDown(1) ;keep looping until ESC pressed
  
  Flip ;swap front and back buffers
	
Wend ; continue until progrgram ends

End Function

Main_Game_Loop()

.mygrid
Data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data 0,51,50,50,50,50,50,50,50,50,50,50,50,50,52, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,60, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,70, 0
Data 0,81,80,80,80,80,80,80,80,80,80,80,80,80,82, 0
Data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0



Thanks, to anyone whom can help me with this wierd error message...

Error Expecting ) here.
in this line-> fruitgrid(cntx,cnty)\picture = CopyImage(hold(grid(cntx,cnty))\picture)

right in the cnty variable middle for some reason.

Thanks.


Rimmsy(Posted 2004) [#2]
Whenever you get problems like this, it's always best to simplify. Regard:
fruitgrid(cntx,cnty)\picture = CopyImage(hold(grid(cntx,cnty))\picture) 

becomes:
grid_ref=grid(cntx,cnty)
image=hold(grid_ref)\picture
fruitgrid(cntx,cnty)\picture = CopyImage(image)


In this instance, blitz is a bit tricky when it comes to arrays and types. so: array(1)\plop usually throws an error. Try:

a.fruitItem=array(1)
a\plop


Rimmsy(Posted 2004) [#3]
Also, includes are easy. Here's an example:
; type.bb
type a
field b
end type


; update.bb
function updateGame()
 ; update here, baby
end function


and in the main file (the file you run) file:
include "type.bb"
include "update.bb"

; create a type

a_new_type.a=new a
a\b=25

updateGame()
end


The location of the main and include files is:
c:\games\my new game\main.bb
c:\games\my new game\update.bb
c:\games\my new game\type.bb