GLBasic forum

Main forum => Bug Reports => Topic started by: josemym2 on 2010-Apr-30

Title: Bug in my isometric prototype
Post by: josemym2 on 2010-Apr-30
when i compliled my program glbasic return this error

"test.gbas"(0) error : wrong argument type :

my code is here:

Code (glbasic) Select
// --------------------------------- //
// Project: test
// Start: Friday, April 30, 2010
// IDE Version: 7.203


// SETCURRENTDIR("Media") // seperate media and binaries?
TYPE object3d
pos[]
old_pos[]
vel[]
size[]
fixedob
objtype
ENDTYPE

TYPE object_group
count
object3d[] AS object3d
ENDTYPE

//GLOBAL Bed AS object3d
GLOBAL Actor AS object3d
GLOBAL facing[],gravity



LOADBMP    "background.png"


main:

GOSUB MoveAll
GOSUB ShowAll

GOTO main

SUB MoveAll:
DIMDATA W[],-2,0,0
DIMDATA E[], 2,0,0
DIMDATA N[],0,2,0
DIMDATA S[],0,-2,0


// Paddles
IF KEY(203) OR KEY(205) OR KEY(200) OR KEY(208)
IF KEY(203) THEN Actor=move(W[],Actor)
IF KEY(205) THEN Actor=move(E[],Actor)

IF KEY(200) THEN Actor=move(N[],Actor)
IF KEY(208) THEN Actor=move(S[],Actor)
ELSE
Actor=stop(Actor)
ENDIF

IF y<0   THEN y=0
IF y>416 THEN y=416


ENDSUB
SUB ShowAll:


PRINT facing[0],facing[1],facing[2]
SHOWSCREEN
ENDSUB

FUNCTION move: offset[],obj3d AS object3d
//GLOBAL facing[],gravity


  //*/ action TO change velocity based on movement/*/

  //*/ offset: the value FOR the velocity: list of 3 integers (vx,vy,vz) /*/
  IF gravity = FALSE
obj3d.vel=offset
DIMDATA zero[], 0,0,0
facing=direction(zero[],offset[]) //vector
// coltime=objects.obj_time.get_time()
  ENDIF
    RETURN obj3d

ENDFUNCTION
FUNCTION stop: obj3d AS object3d
//GLOBAL gravity,vel[]
  //' Sets the objects velocity IN all directions TO zero.
  IF gravity = FALSE
obj3d.vel[0]=0
obj3d.vel[1]=0
obj3d.vel[2]=0
  ENDIF
  RETURN obj3d
ENDFUNCTION
FUNCTION direction: v1[], v2[]
   // defines a facing vector (uses 1 FOR positive AND -1 FOR negative OR zero FOR same) of v1 TO v2 """
LOCAL vout[],i;DIM vout[2]

   FOR i  = 0 TO 2
  IF v1[i]-v2[i]<0
  vout[i]=1
  ELSEIF v1[i]-v2(i)>0
  vout[i]=-1
  ELSE
  vout[i]=0
  ENDIF
   NEXT
   RETURN vout[]

ENDFUNCTION


whatÃ,´s wrong ? the return array in the functions?

Please help me
Title: Re: Bug in my isometric prototype
Post by: Ian Price on 2010-Apr-30
That code alone produces no errors.

Code (glbasic) Select

   // SETCURRENTDIR("Media") // seperate media and binaries?
TYPE object3d
   pos[]
   old_pos[]
   vel[]
   size[]
   fixedob
   objtype
ENDTYPE

SETSCREEN 640,480,1

PRINT "HELLO",10,10

SHOWSCREEN

KEYWAIT


Runs fine.

It must be something else in your code.

Title: Re: Bug in my isometric prototype
Post by: josemym2 on 2010-Apr-30
The error does not show more information.

I think it can be in the allocations and the return of the functions, but I am starting with this language and need help
Title: Re: Bug in my isometric prototype
Post by: Ian Price on 2010-Apr-30
Oops! Sorry, I completely missed the bottom part of the code, due to not seeing the scrollbar! D'oh! :S

Ouch! That code is a right mess - I really can't see what's what, with all the GOSUBS and RETURNS. You've got variables all over the place with no idea what does what. :noggin:

What is your code supposed to be doing? Can you describe what you want, as what you've got seems overly complicated no matter what it is.

[EDIT]

Here's a possible problem, but not the solution -   

ELSEIF v1-v2(i)>0

You've written v2() when it should be v2[]
Title: Re: Bug in my isometric prototype
Post by: Kitty Hello on 2010-Apr-30
 :coke: We deffo need the "buy me a beer" option back.
Title: Re: Bug in my isometric prototype
Post by: josemym2 on 2010-Apr-30
 :booze:
=D
I found an error in the code
Code (glbasic) Select

FUNCTION move: offset[],obj3d AS object3d
//GLOBAL facing[],gravity


  //*/ action TO change velocity based on movement/*/

  //*/ offset: the value FOR the velocity: list of 3 integers (vx,vy,vz) /*/
  IF gravity = FALSE
obj3d.vel=offset
DIMDATA zero[], 0,0,0
facing=direction(zero[],offset[]) //vector
// coltime=objects.obj_time.get_time()
  ENDIF
    RETURN obj3d

ENDFUNCTION


must be ....
Code (glbasic) Select

FUNCTION move as object3d: offset[],obj3d AS object3d
//GLOBAL facing[],gravity


  //*/ action TO change velocity based on movement/*/

  //*/ offset: the value FOR the velocity: list of 3 integers (vx,vy,vz) /*/
  IF gravity = FALSE
obj3d.vel=offset
DIMDATA zero[], 0,0,0
facing=direction(zero[],offset[]) //vector
// coltime=objects.obj_time.get_time()
  ENDIF
    RETURN obj3d

ENDFUNCTION


FUNCTION move as object3d <-- this is the error
Thanks