Wo ist hier der Fehler??

Previous topic - Next topic

Nobody

Code (glbasic) Select
// --------------------------------- //
// Project: qaswd
// Start: Tuesday, April 14, 2009
// IDE Version: 6.222


// DEMO-VERSION:
// Missing features:
// No time limit during gameplay
// No watermark in executables

TYPE SHOT
x
y
ENDTYPE


TYPE FOE
x
y
speed = 3
amour = 4
ENDTYPE

TYPE BOOM
x
y
time
ENDTYPE

LOADSPRITE "ship.bmp", 0
LOADSPRITE "shot.png", 1
LOADSPRITE "bug.png",  2
LOADSPRITE "boom.png", 3

LOCAL shots [] AS SHOT
LOCAL bugs[] AS FOE
LOCAL poof[] AS BOOM


WHILE TRUE
INC playerx, MOUSEAXIS(0)
playerx = MAX(MIN(playerx, 800),  32)

IF MOUSEAXIS(3) AND delay<GETTIMERALL()
LOCAL shot AS SHOT
shot.x = playerx
shot.y = 500
DIMPUSH shots[], shot
dealy = GETTIMERALL()+100
ENDIF

time = GETTIMERALL()
IF time>nextbug
nextbug = time + 500
LOCAL b AS FOE
DIMPUSH bugs[], b
ENDIF

FOREACH bug IN bugs[]
INC bug. x, bug.speed
IF bug.x<0 OR bug.x>750
bug.speed = -bug.speed
INC bug.y, 32
ENDIF

didhit=FALSE
FOREACH pop IN shots[]
IF BOXCOLL(pop.x, pop.y, 8,8, bug.x, bug.y, 32,32)
didhit=TRUE
DELETE pop
ENDIF
NEXT
IF didhit
LOCAL p AS BOOM
p.x = bug.x
p.y = bug.y
p.time = time
DIMPUSH poof[], p
DELETE bug
ENDIF

DRAWSPRITE 2, bug.x, bug.y
NEXT

FOREACH p IN poof[]
pos = (time = p-time)/100 // 0 ... 1
IF pos > 1 THEN DELETE p
ROTOZOOMSPRITE 3, p.x, p.y, pos*1000, 1 + pos*3





FOREACH pop IN shots[]
DEC pop.y, 5
IF pop.y<0 THEN DELETE pop

DRAWSPRITE 1, pop.x, pop.y



NEXT

DRAWSPRITE 0, playerx, 500





SHOWSCREEN
WEND



ICh finde den nicht es l?st dich nciht starten.

Wenn falsches topic bitte verschieben

Moru

These are what I could find, make sure you activate "debug mode" before you start the game, you get more error messages that way.

Code (glbasic) Select


line 61:
NEXT // Missing a next here I think

line 87:
pos = (time = p-time)/100 // 0 ... 1 // Don't think you can use = more than once on a line?

line 90:
NEXT // Missing a next here I think


Kosta

Was meinst du mit "Es l?sst sich nicht starten"?

der Kompiliervorgang?  ..was kommt denn f?r eine Meldung?
Intel QuadCore, Geforce8600GT,512MB,4GB Ram, 26" TFT
HP nw8440 Schläppy
GP2X Mk2 (Firmware 3.0)

GLBASIC Blog:
http://www.glbasic.com/forum/index.php?blog=51.0

Kitty Hello

Wie Moru schon sagte, die letzen beiden FOREACH Schleifen haben kein "NEXT".

Achtung:

pos = (time = p-time)/100 // 0 ... 1

(time = p-time) -> p=0 -> TRUE, p<>0 ->FALSE
pos = (TRUE oder FALSE) / 100 -> 0 ODER 1

Was Du willst:
Code (glbasic) Select

time = p-time
pos = time /100.0 // .0, damit sicher eine Floating point division gemacht wird, falls "time" eine nat?rliche Zahl ist (LOCAL time%)

Nobody

Code (glbasic) Select
// --------------------------------- //
// Project: qaswd
// Start: Tuesday, April 14, 2009
// IDE Version: 6.222


// DEMO-VERSION:
// Missing features:
// No time limit during gameplay
// No watermark in executables

TYPE SHOT
x
y
ENDTYPE


TYPE FOE
x
y
speed = 3
amour = 4
ENDTYPE

TYPE BOOM
x
y
time
ENDTYPE

LOADSPRITE "ship.bmp", 0
LOADSPRITE "shot.png", 1
LOADSPRITE "bug.png",  2
LOADSPRITE "boom.png", 3

LOCAL shots [] AS SHOT
LOCAL bugs[] AS FOE
LOCAL poof[] AS BOOM


WHILE TRUE
INC playerx, MOUSEAXIS(0)
playerx = MAX(MIN(playerx, 800),  32)

IF MOUSEAXIS(3) AND delay<GETTIMERALL()
LOCAL shot AS SHOT
shot.x = playerx
shot.y = 500
DIMPUSH shots[], shot
dealy = GETTIMERALL()+100
ENDIF

time = GETTIMERALL()
IF time>nextbug
nextbug = time + 500
LOCAL b AS FOE
DIMPUSH bugs[], b
ENDIF

FOREACH bug IN bugs[]
INC bug. x, bug.speed
IF bug.x<0 OR bug.x>750
bug.speed = -bug.speed
INC bug.y, 32
ENDIF
NEXT

didhit=FALSE
FOREACH pop IN shots[]
IF BOXCOLL(pop.x, pop.y, 8,8, bug.x, bug.y, 32,32)
didhit=TRUE
DELETE pop
ENDIF
NEXT
IF didhit
LOCAL p AS BOOM
p.x = bug.x
p.y = bug.y
p.time = time
DIMPUSH poof[], p
   [font=Verdana][color=red][b]DELETE bug[/b][/color][/font]
ENDIF

DRAWSPRITE 2, bug.x, bug.y
NEXT

FOREACH p IN poof[]
pos = (time = p-time)/100 // 0 ... 1
IF pos > 1 THEN DELETE p
ROTOZOOMSPRITE 3, p.x, p.y, pos*1000, 1 + pos*3





FOREACH pop IN shots[]
DEC pop.y, 5
IF pop.y<0 THEN DELETE pop

DRAWSPRITE 1, pop.x, pop.y



NEXT

DRAWSPRITE 0, playerx, 500





SHOWSCREEN
WEND


so das next habe ich hin gemacht jetzt zeigt er mir den n?hster fehler an

er ist makiert

BumbleBee

Lies nochmal was Moru und Gernot geschrieben haben, und dann kuck nochmal genau auf deinen Code. Und der Compiler sagt dir ja auch noch genau was ihm nicht passt. :P

Cheers
The day will come...

CPU Intel(R) Core(TM) i5-3570k, 3.4GHz, AMD Radeon 7800 , 8 GB RAM, Windows 10 Home 64Bit

Nobody

Code (glbasic) Select
// --------------------------------- //
// Project: qaswd
// Start: Tuesday, April 14, 2009
// IDE Version: 6.222


// DEMO-VERSION:
// Missing features:
// No time limit during gameplay
// No watermark in executables

TYPE SHOT
x
y
ENDTYPE


TYPE FOE
x
y
speed = 3
amour = 4
ENDTYPE

TYPE BOOM
x
y
time
ENDTYPE

LOADSPRITE "ship.png", 0
LOADSPRITE "shot.png", 1
LOADSPRITE "bug.png",  2
LOADSPRITE "boom.png", 3

LOCAL shots [] AS SHOT
LOCAL bugs[] AS FOE
LOCAL poof[] AS BOOM


WHILE TRUE
INC playerx, MOUSEAXIS(0)
playerx = MAX(MIN(playerx, 800),  32)

IF MOUSEAXIS(3) AND delay<GETTIMERALL()
LOCAL shot AS SHOT
shot.x = playerx
shot.y = 500
DIMPUSH shots[], shot
dealy = GETTIMERALL()+100
ENDIF

time = GETTIMERALL()
IF time>nextbug
nextbug = time + 500
LOCAL b AS FOE
DIMPUSH bugs[], b
ENDIF

FOREACH bug IN bugs[]
INC bug. x, bug.speed
IF bug.x<0 OR bug.x>750
bug.speed = -bug.speed
INC bug.y, 32
ENDIF
NEXT

didhit=FALSE
FOREACH pop IN shots[]
IF BOXCOLL(pop.x, pop.y, 8,8, bug.x, bug.y, 32,32)
didhit=TRUE
DELETE pop
ENDIF
NEXT
IF didhit
LOCAL p AS BOOM
p.x = bug.x
p.y = bug.y
time = p-time
DIMPUSH poof[], p
DELETE BUG
ENDIF

DRAWSPRITE 2, bug.x, bug.y
NEXT

FOREACH p IN poof[]
pos = time /100.0 // .0,
IF pos > 1 THEN DELETE p
ROTOZOOMSPRITE 3, p.x, p.y, pos*1000, 1 + pos*3





FOREACH pop IN shots[]
DEC pop.y, 5
IF pop.y<0 THEN DELETE pop

DRAWSPRITE 1, pop.x, pop.y



NEXT

DRAWSPRITE 0, playerx, 500





SHOWSCREEN
WEND











So habe es verbesser er zeigt mir bei DELETE bug an
"qaswd.gbas"(81) error : wrong argument type : Must be:

Schranz0r

Mach aus :
Code (glbasic) Select
DELETE BUG


ein

Code (glbasic) Select
DELETE bug

Gro?- und Kleinschreibung bitte in GLBasic beachten!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Nobody

habe ich gemacht zeigt da immer noch ein fehler an

"qaswd.gbas"(81) error : wrong argument type : Must be:

Schranz0r

Du hast massig For - Next falsch gesetzt!
Fehler mit "p-time" muss sein "p.time".

Fang doch nochmal von vorne an, und bring da ein wenig Struktur rein.

Wichtig ist, sauberes Einr?cken.(teilweise vorhanden)

zum Grundverst?ndnis
Code (glbasic) Select

FOREACH shot IN TShots[]

// Code was mit dem schuss gemacht wird
// z.b bewegen
DEC shot.y, 2
DRAWSPRITE shot.pic, shot.x, shot.y
// usw...

FOREACH enemy IN TEnemy[]

// hier kannst du shot und enemy verwenden!
IF SPRCOLL(enemy.pic, enemy.x, enemy.y, shot.pic, shot.x, shot.y)
DELETE enemy
DELETE shot
INC Score, 100
ENDIF

NEXT

// Hier ist enemy nicht mehr aufrufbar!

NEXT

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Nobody

ok werde noch mal von vorne anfangen

Nobody

Code (glbasic) Select
// --------------------------------- //
// Project: Blaster
// Start: Thursday, April 05, 2007
// IDE Version: 4.145


TYPE SHOT
x
y
ENDTYPE

TYPE FOE
x
y
speed=3
amour=4
ENDTYPE

TYPE BOOM
x
y
time
ENDTYPE



LOCAL newshot AS SHOT
LOCAL newbug  AS FOE


LOCAL shots[] AS SHOT
LOCAL bugs[] AS FOE
LOCAL poof[] AS BOOM




LOADSPRITE "ship.PNG", 0
LOADSPRITE "shot.PNG", 1
LOADSPRITE "bug.PNG",  2
LOADSPRITE "boom.PNG", 3






playerx = 320
WHILE TRUE

INC playerx, MOUSEAXIS(0)

playerx=MAX(MIN(playerx,600),40)


IF MOUSEAXIS(3) AND delay

newshot.x = playerx
newshot.y = 400

DIMPUSH shots[], newshot

delay = GETTIMERALL() + 100
ENDIF


time = GETTIMERALL()
IF time>nextbug
nextbug = time + 500
DIMPUSH bugs[], newbug
ENDIF

FOREACH bug IN bugs[]
INC bug.x, bug.speed
IF bug.x<0 OR bug.x>620
INC bug.y, 32
bug.speed = -bug.speed
ENDIF
didhit=FALSE
FOREACH pop IN shots[]
IF BOXCOLL(pop.x, pop.y, 8,8, bug.x, bug.y, 32,32)
didhit=TRUE
DELETE pop
ENDIF
NEXT
IF didhit
LOCAL p AS BOOM
p.x = bug.x
p.y = bug.y
p.time = time
DIMPUSH poof[], p
DELETE bug
ENDIF
DRAWSPRITE 2, bug.x, bug.y
NEXT


FOREACH p IN poof[]
LOCAL pos = (time - p.time) / 1000
IF pos > 1 THEN DELETE p
ALPHAMODE 1-pos
ROTOZOOMSPRITE 3, p.x, p.y, pos*1000, 1+pos*3
NEXT
ALPHAMODE 0




FOREACH pop IN shots[]

DEC pop.y, 5

IF pop.y<0 THEN DELETE pop


DRAWSPRITE 1, pop.x, pop.y
NEXT


DRAWSPRITE 0, playerx, 400

SHOWSCREEN
WEND



hier ist es noch mal neu jetzt funzt auch alles er l?dt aber die bilder nicht er startet das pogramm schlie?t es aber sofort.

Moru

You declare p as different types, compiler don't like that. Always use a different name for each type you declare to keep out of trouble :-)

Nobody

kann mir einer den code nicht richtig machen ich klicke auf pogramm starten dann  schreibt er unten
Code (glbasic) Select

_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2009.098 - 2D, WIN32
Wordcount:0 commands

compiling:

linking:
erfolgreich
_______________________________________
*** Fertig ***
Dauer: 1.5 sek. Zeit: 11:28
Erstellen: 1 erfolgreich.



dann startet er kurz das pogramm man sieht den schrift zug loading und dann schlie? sich alles wieder

Kitty Hello

Code (glbasic) Select

time = GETTIMERALL()
IF MOUSEAXIS(3) AND delay<time

Das musste man vertauschen, damit man schie?en kann.

Seltsamerweise hatte ich kl. Probleme als ich von Konsole auf Windows umgeschalten habe.

Bitte schalte den Debug Modus einmal aus, und wieder neu ein.