GLBasic forum

Other languages => GLBasic - de => Topic started by: mull on 2007-Jun-03

Title: Type Deklaration
Post by: mull on 2007-Jun-03
TYPE tWaffe
    png
 ENDTYPE
 GLOBAL Img AS tWaffe

 //
 FUNCTION InitGrafiken:
   Img.png = 1
   //LOADSPRITE PrgPfad$ + "Boden_Stein.png" , Img.png
ENDFUNCTION


Kommt dieser Fehler
error : wrong argument type : TYPE  is not declared

Aber Img ist docvh oben als Global deklarier ?t
Title: Type Deklaration
Post by: Schranz0r on 2007-Jun-03
Hiho :D

Na neuer .... =)

Code (glbasic) Select
TYPE t_Waffe
pic
num
ENDTYPE

LOCAL W AS t_Waffe
LOCAL t_Waffen[] AS t_Waffe


LOCAL Klicks

FOR i = 0 TO 9
W.pic = RND(10)
W.num = i
DIMPUSH t_Waffen[],W
NEXT

FOREACH check IN t_Waffen[]
PRINT check.pic, 10, check.num*10
NEXT

SHOWSCREEN
KEYWAIT
END
um dir mal was simples zu zeigen :)
Also Types in Functionen rein hab ich jetzt noch nicht geschaft, laut Gernot wohl auch nicht möglich, bzw. nicht gut !
Title: Type Deklaration
Post by: mull on 2007-Jun-03
Quote from: Schranz0rHiho :D

, laut Gernot wohl auch nicht möglich, bzw. nicht gut !
Das ist schade, wenn ich aber was Gobal Deklariere, dann weil ich es immer und ÜBERALL haben will.
Title: Type Deklaration
Post by: Schranz0r on 2007-Jun-03
Pass mal auf, hab was für dich :D


Code (glbasic) Select
TYPE t_Waffe
pic
num
ENDTYPE

GLOBAL W AS t_Waffe
GLOBAL t_Waffen[] AS t_Waffe

WHILE TRUE

IF timer < GETTIMERALL()
init_pic()
timer = GETTIMERALL()+100
ENDIF

draw_pic()

SHOWSCREEN
WEND
END


FUNCTION init_pic:

GLOBAL nummer
IF W.num < 10
INC nummer,1
W.pic = RND(10)
W.num = nummer
DIMPUSH t_Waffen[],W
ENDIF

ENDFUNCTION

FUNCTION draw_pic:

FOREACH check IN t_Waffen[]
PRINT check.pic, 0, check.num*10
NEXT

ENDFUNCTION
Title: Type Deklaration
Post by: Kitty Hello on 2007-Jun-03
Der Code ganz oben geht bei mir. Ich hab' aber ewig viel am Compiler geändert. Kommt diese Woche noch als Update.
Title: Type Deklaration
Post by: mull on 2007-Jun-03
@Schranz0r
Jo, das flutscht. Dank dir.
Title: Type Deklaration
Post by: Schranz0r on 2007-Jun-03
kein Problem...


ach Gernot

Machst du jetzt die arrays automatisch?

also fällt dann ein:

LOCAL Var[] IN typename


weg?