Dim brett[a][b] mit werten füllen funktioniert irgendwie nich so

Previous topic - Next topic

Schranz0r

LEVEL[X][Y] = Steinsorte

so würde ich es machen ;)
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

x-tra

soweit bin ich ja schon gewesen, nur will ich auch animationen einbinden, bzw. wenn steine fallen, sollen diese auch fallen und nicht nur die position ändern.ich denke dazu müssen koordinaten vorhanden sein, um die tiles so verschieben.und so muss ich ja auch jedem feld koordinaten zuweisen.

hier mein bisheriger code:

Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
LIMITFPS 20
 x=0
 y=0
 TileSize = 30
 tileX = 10
 tileY = 10
                    DIM feld[tileX][tileY]



feld[1][1] = 2
feld[1][2] = 1
feld[1][3] = 3
feld[2][1] = 2
feld[3][0] = 3
   WHILE TRUE


      FOR x = 0 TO tileX-1
      FOR y = 0 TO tileY-1

     IF y <> 9

             IF feld[x][y+1] = 0
                 feld[x][y+1] = feld[x][y]
                 feld[x][y] = 0

             ENDIF

     ENDIF



              IF feld[x][y] = 0 THEN DRAWRECT (x*TileSize),(y*TileSize), TileSize, TileSize, RGB(0, 0, 0)

              IF feld[x][y] = 1 THEN DRAWRECT (x*TileSize),(y*TileSize), TileSize, TileSize, RGB(255, 0, 0)

              IF feld[x][y] = 2 THEN DRAWRECT (x*TileSize),(y*TileSize), TileSize, TileSize, RGB(0, 255, 0)

             IF feld[x][y] = 3 THEN  DRAWRECT (x*TileSize),(y*TileSize), TileSize, TileSize, RGB(0, 0, 255)

      NEXT
     NEXT

 SHOWSCREEN
WEND
erstmal so zum test, und weil ich den code umschreiben musste.
die steine fallen nach unten, aber ich würde das halt gern sehen, wie sie langsam nach unten gleiten, hat jemand eine idee?

Schranz0r

Du musst dir die Zielposition merken und dann pro durchlauf eins nach unten wandern.
Wenn Ziel erreicht, dann  ist die neue Position der Wert vom gewanderten Stein :)
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

x-tra

Uhhh kannst du mir das mal codeschnippseln, wäre lieb.

Also den Gedanken hatte ich schon ähnlich, dass der Wert vom vorherigen Feld erst nach dem nach unten bewegen angenommen wird.

Wie merke ich mir diese Position?Da es ja theoretisch für viele Steine zutreffen kann.

Achja, das Drawrect wird später durch ein tile bzw. sprite ersetzt.


so hab das jetzt mal umgestellt auf sprites und mit einem schicken hintergrund.im anhang mal zum testen, und vielleicht nen tipp geben.

game.zip - 0.40MB


so bin etwas weiter, gernot hat mir in einem anderen thread ein wenig weitergeholfen.



Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
SETSCREEN 600, 600, 1
LIMITFPS 60
 x=0
 y=0
 TileSize = 50   //laenge/breite der sprites
 tiles = 100        
 rand = 50    //Randverschiebung
  DIM feld[tiles]


feld[40] = 2
feld[50] = 2
feld[51] = 2


LOADSPRITE "box1.bmp",1
LOADSPRITE "box2.bmp",2
LOADSPRITE "box3.bmp",3
LOADSPRITE "boxclear.png",4
LOADBMP "hintergrund.bmp"

WHILE TRUE


  FOR x = 0 TO tiles-1

         IF x < 90

             IF feld[x+10] = 0
                 feld[x+10] = feld[x]
                 feld[x] = 0
             ENDIF

          ENDIF
                                     
                                                                      boxx = ((MOD(x,10)*TileSize)+rand)
                                                                      boxy = (((INTEGER(x/10))*TileSize)+rand)


              IF feld[x] = 0 THEN DRAWSPRITE 4, (boxx),(boxy)

              IF feld[x] = 1 THEN DRAWSPRITE 1, (boxx),(boxy)

              IF feld[x] = 2 THEN DRAWSPRITE 2, (boxx),(boxy)

              IF feld[x] = 3 THEN  DRAWSPRITE 3, (boxx),(boxy)
             
             
  NEXT
       SHOWSCREEN
WEND
jetzt muss ich nur noch das nach unten wandern hinbekommen....


so update, bzw. neuer code.
wollte nur nen type erstellen, aber kommt fehler.

bitteschön, bzw. gernot kannst du mal schauen?

Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
SETSCREEN 600, 600, 1
LIMITFPS 60
 x=0
 y=0
 TileSize = 50   //laenge/breite der sprites
 tiles = 100        
 rand = 50    //Randverschiebung
             
///Typedefinition            
           TYPE Tinfo
             altx
             alty
             neux
             neuy
             ENDTYPE
 
             LOCAL feld[] AS Tinfo  
///Ende Typedefinition

///Dimensionierung
  DIM feld[tiles]
///Ende Dimensionierung

///Zufällige Sprites als Test
feld[40] = 2
feld[50] = 2
feld[51] = 2
///.....


///Material laden
LOADSPRITE "box1.bmp",1
LOADSPRITE "box2.bmp",2
LOADSPRITE "box3.bmp",3
LOADSPRITE "boxclear.png",4
LOADBMP "hintergrund.bmp"
///Ende Material laden

///Hauptschleife
WHILE TRUE


  FOR x = 0 TO tiles-1

         IF x < 90

             IF feld[x+10] = 0
                 feld[x+10] = feld[x]
                 feld[x] = 0
             ENDIF

          ENDIF
                                     
                                                                      boxx = ((MOD(x,10)*TileSize)+rand)
                                                                      boxy = (((INTEGER(x/10))*TileSize)+rand)


              IF feld[x] = 0 THEN DRAWSPRITE 4, (boxx),(boxy)

              IF feld[x] = 1 THEN DRAWSPRITE 1, (boxx),(boxy)

              IF feld[x] = 2 THEN DRAWSPRITE 2, (boxx),(boxy)

              IF feld[x] = 3 THEN  DRAWSPRITE 3, (boxx),(boxy)
             
             
  NEXT
       SHOWSCREEN
WEND

///Ende Hauptschleife
hier die Fehlermeldung:

Code (glbasic) Select
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2008.073 - 3D, NET
"aqua.gbas"(7) warning : implicitly created GLOBAL  : x
"aqua.gbas"(8) warning : implicitly created GLOBAL  : y
"aqua.gbas"(9) warning : implicitly created GLOBAL  : TileSize
"aqua.gbas"(10) warning : implicitly created GLOBAL  : tiles
"aqua.gbas"(11) warning : implicitly created GLOBAL  : rand
"aqua.gbas"(58) warning : implicitly created GLOBAL  : boxx
"aqua.gbas"(59) warning : implicitly created GLOBAL  : boxy
Wordcount:35 commands

compiling:
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:39: error: no match for 'operator=' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](40, 0, 0, 0) = 2'
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp_class.h:18: note: candidates are: __GLBASIC__::Tinfo& __GLBASIC__::Tinfo::operator=(const __GLBASIC__::Tinfo&)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:41: error: no match for 'operator=' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](50, 0, 0, 0) = 2'
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp_class.h:18: note: candidates are: __GLBASIC__::Tinfo& __GLBASIC__::Tinfo::operator=(const __GLBASIC__::Tinfo&)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:43: error: no match for 'operator=' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](51, 0, 0, 0) = 2'
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp_class.h:18: note: candidates are: __GLBASIC__::Tinfo& __GLBASIC__::Tinfo::operator=(const __GLBASIC__::Tinfo&)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:68: error: no match for 'operator==' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0) == 0'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note: candidates are: DGInt __GLBASIC__::operator==(int, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(int, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, double)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, double)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:73: error: no match for 'operator=' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0) = 0'
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp_class.h:18: note: candidates are: __GLBASIC__::Tinfo& __GLBASIC__::Tinfo::operator=(const __GLBASIC__::Tinfo&)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:83: error: no match for 'operator==' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0) == 0'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note: candidates are: DGInt __GLBASIC__::operator==(int, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(int, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, double)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, double)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:86: error: no match for 'operator==' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0) == 1'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note: candidates are: DGInt __GLBASIC__::operator==(int, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(int, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, double)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, double)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:89: error: no match for 'operator==' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0) == 2'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note: candidates are: DGInt __GLBASIC__::operator==(int, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(int, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, double)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, double)
C:\Users\Nutzer\AppData\Local\Temp\glbasic\gpc_temp0.cpp:92: error: no match for 'operator==' in '(&feld)->__GLBASIC__::DGArray::operator() [with T = __GLBASIC__::Tinfo](#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0) == 3'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note: candidates are: DGInt __GLBASIC__::operator==(int, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(int, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(float, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(double, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(__GLBASIC__::CGStr, double)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, int)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, float)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:232: note:                 DGInt __GLBASIC__::operator==(const __GLBASIC__::DGStr&, double)
*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren
_______________________________________
*** Fertig ***
Zeit: 1.7 sek
Erstellen: 0 erfolgreich
*** 1 FEHLGESCHLAGEN ***

Kitty Hello

Code (glbasic) Select
LOCAL feld[] AS Tinfo  
DIM feld[tiles]
feld[40] = 2
Aua! feld[] ist ein Feld von "Tinfo"s. Aber Du weist einem Tinfo den Wert "2" zu!?
Also - entweder feld[] ist nur ein Feld von Zahlen, oder
feld[40].altx = 2
oder so... Kapiert?

Schon doof, dass der Compiler nicht meckert. Muss ich ändern.

x-tra

achso, ich dachte man kann einmal dem feld[] einen wert zuweisen, und die types sind seperat.
mit der definition eines types fällt somit die möglichkeit weg dem array feld[] einen einzelnen wert zuzuweisen, weil an dessen stelle sozusagen jetzt das type steht.(ein hub für dim feld[] sozusagen)

richtig?

so hier?

Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
SETSCREEN 600, 600, 1
LIMITFPS 60
 x=0
 y=0
 TileSize = 50   //laenge/breite der sprites
 tiles = 100        
 rand = 50    //Randverschiebung
             
///Typedefinition            
           TYPE Tinfo
             altx
             alty
             neux
             neuy
             box
             ENDTYPE
 
             LOCAL feld[] AS Tinfo  
///Ende Typedefinition

///Dimensionierung
  DIM feld[tiles]
///Ende Dimensionierung

///Zufällige Sprites als Test
feld[40].box = 2
feld[50].box = 2
feld[51].box = 2
///.....


///Material laden
LOADSPRITE "box1.bmp",1
LOADSPRITE "box2.bmp",2
LOADSPRITE "box3.bmp",3
LOADSPRITE "boxclear.png",4
LOADBMP "hintergrund.bmp"
///Ende Material laden

///Hauptschleife
WHILE TRUE


  FOR x = 0 TO tiles-1

         IF x < 90

             IF feld[x+10].box = 0
                 feld[x+10].box = feld[x].box
                 feld[x].box = 0
             ENDIF

          ENDIF
                                     
                                                                      boxx = ((MOD(x,10)*TileSize)+rand)
                                                                      boxy = (((INTEGER(x/10))*TileSize)+rand)


              IF feld[x].box = 0 THEN DRAWSPRITE 4, (boxx),(boxy)

              IF feld[x].box = 1 THEN DRAWSPRITE 1, (boxx),(boxy)

              IF feld[x].box = 2 THEN DRAWSPRITE 2, (boxx),(boxy)

              IF feld[x].box = 3 THEN  DRAWSPRITE 3, (boxx),(boxy)
             
             
  NEXT
       SHOWSCREEN
WEND

///Ende Hauptschleife

x-tra

Ich wollte jetzt keinen extra Thread aufmachen, da ich immer noch an meinem Quellcode hänge, und es hilft aller Kaffee nichts, ich muss feststellen, dass man mit der Zeit die eigenen Fehler nicht mehr sieht.

Kann mir jemand, vielleicht sogar Schranzi helfen?fg.

Ich hab das jetzt mal mit dem Wandern der Sprites versucht, aber irgendwas mach ich wohl total falsch, aber ich seh grad im Moment garnicht durch.
In paar Stunden sieht das wohl schonwieder anders aus, aber grad blick ichs net.

Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
SETSCREEN 600, 600, 1
LIMITFPS 60
 x=0
 y=0
 TileSize = 50   //laenge/breite der sprites
 tiles = 100        
 randy = 50    //Randverschiebung
 randx = 49          
///Typedefinition            
           TYPE Tinfo
             posx
             posy
             posneuy
             box
             ENDTYPE
 
             LOCAL feld[] AS Tinfo  
///Ende Typedefinition

///Dimensionierung
  DIM feld[tiles]
///Ende Dimensionierung

///Zufällige Sprites als Test
feld[1].box = 2
feld[2].box = 3
feld[3].box = 2
feld[4].box = 2
feld[5].box = 3
feld[6].box = 2
feld[7].box = 2
feld[8].box = 2
feld[9].box = 3
feld[10].box = 2
///.....


///Material laden
LOADSPRITE "pfeil.png",20
LOADSPRITE "box1.bmp",1
LOADSPRITE "box2.bmp",2
LOADSPRITE "box3.bmp",3
LOADSPRITE "boxclear.png",4
LOADBMP "hintergrund.bmp"
///Ende Material laden

///Hauptschleife
WHILE TRUE

  FOR x = 0 TO tiles-1

         IF x < 90
//////////////////////////////////////////////////////////////////////////////////////////////////////
             IF feld[x+10].box = 0
                 stp = 1
                 feld[x].posneuy = feld[x].posy + stp
                 IF feld[x].posy = feld[x+10].posy
                        feld[x+10].box = feld[x].box
                        stp = 0
                 ENDIF      
                 feld[x].box = 0
             ENDIF

          ENDIF
                                           boxx = ((MOD(x,10)*TileSize)+randx)
                                                    feld[x].posx = boxx                
                                           boxy = (((INTEGER(x/10))*TileSize)+randy)
                                                    feld[x].posy = boxy

              IF feld[x].box = 0 THEN DRAWSPRITE 4, (boxx),(boxy)

              IF feld[x].box = 1 THEN DRAWSPRITE 1, (boxx),(boxy)

              IF feld[x].box = 2 THEN DRAWSPRITE 2, (boxx),(boxy)

              IF feld[x].box = 3 THEN  DRAWSPRITE 3, (boxx),(boxy)
             
  NEXT
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//mausbewegung
MOUSESTATE mx, my, b1, b2
DRAWSPRITE 20, mx, my
//mausbewegung ende

       SHOWSCREEN
WEND

///Ende Hauptschleife
ich entschuldige mich auch gleich mal wegen dem doppelpost, kann auch gern zusammengeführt werden, nur ich wollt schnell für aufmerksamkeit sorgen, da ich grad laune hab das spiel bald fertig zu haben.

Schranz0r

Ich hab gestern auch mal ein wenig versucht, mach aber selber einen Fehler beim runterrutschen ^^
Muss erst selber gucken dann stell ich es online für jedermann ;)
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

x-tra

na aber ich bin hoffentlich mal schon nahe dran, so bisschen positives denken halt.
aber ich wart auf deinen post, ich blick grad nix mehr.

Kitty Hello

so...
Code (glbasic) Select
IF block[x][y] = leer
 FOR neuy = y-1 TO 1 STEP -1
    block[x][neuy] = block[x][neuy-1]
 NEXT
 block[x][0] = neuer_zufallsblock();

ENDIF

x-tra

ich hab nur noch ein eindimensionales array, also block
  • [y]  gibts bei mir nicht mehr.es sei denn ich habe deinen code falsch interpretiert.

aber das habe ich sowieso, denn ich hab ihn versucht an meinen obigen post anzupassen, geht nicht.

ich hab dann mal selber überlegt, und war bei folgender lösung:

1. Ursprungsfeld mit 0 sozusagen vom sichtbaren sprite entfernen.
2. mittels drawsprite beginnen an den x, y koordinaten des ursprungssprites auf der y koordinate nach unten wandern.
3. wenn y position vom zielsprite erreicht, zielfeld feld
  • .box mit temporär gespeicherter information gleich wie das fallende sprite setzen.

nur die umsetzung bekomm ich nicht hin.

es sieht aus wie vorher, nr ein sprite hat eine position wo es nun garnicht hingehört, nämlich nicht mehr im spielfeld, sondern im rahmen.

mmmm gernot, kannst du eventuell ein paar easy comments bei deinem lösungsvorschlag posten, zum besseren verständnis.

und auf schran0rs lösung bin ich mal gespannt, ist bestimmt total einfach, man muss nur drauf kommen...


[edit] okay auf ein neues, denke es wäre richtig, aber es funktioniert nicht, obwohl ich dachte es müsste klappen.vielleicht ja jemand wo der fehler liegt.

Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
SETSCREEN 600, 600, 1
LIMITFPS 60
 x=0
 y=0
 TileSize = 50   //laenge/breite der sprites
 tiles = 100
 randy = 50    //Randverschiebung
 randx = 49
///Typedefinition
           TYPE Tinfo
             posx
             posy
             posneuy
             box
             alt
             marker
             zahl
             boxalt
             ENDTYPE

             LOCAL feld[] AS Tinfo
///Ende Typedefinition

///Dimensionierung
  DIM feld[tiles]
///Ende Dimensionierung

///Zufällige Sprites als Test
feld[1].box = 2
feld[2].box = 3
feld[3].box = 2
feld[4].box = 2
feld[5].box = 3
feld[6].box = 2
feld[7].box = 2
feld[8].box = 2
feld[9].box = 3
feld[10].box = 2
///.....


///Material laden
LOADSPRITE "pfeil.png",20
LOADSPRITE "box1.bmp",1
LOADSPRITE "box2.bmp",2
LOADSPRITE "box3.bmp",3
LOADSPRITE "boxclear.png",4
LOADBMP "hintergrund.bmp"
///Ende Material laden

///Hauptschleife
WHILE TRUE

  FOR x = 0 TO tiles-1



IF x < 90

      IF feld[x+10].box = 0
          IF feld[x].marker = 0
           feld[x].alt = feld[x].posy
            feld[x].zahl = 50
             feld[x].boxalt=feld[x].box
          ENDIF

          feld[x].marker = 1

          DRAWSPRITE feld[x].box, feld[x].posx, (feld[x].alt-feld[x].zahl)
          feld[x].box = 0
          feld[x].zahl=feld[x].zahl+1
          IF feld[x].alt-feld[x].zahl = feld[x+10].posy THEN feld[x+10].box = feld[x].boxalt

      ENDIF
ENDIF


                                           boxx = ((MOD(x,10)*TileSize)+randx)
                                                    feld[x].posx = boxx
                                           boxy = (((INTEGER(x/10))*TileSize)+randy)
                                                    feld[x].posy = boxy

              IF feld[x].box = 0 THEN DRAWSPRITE 4, (boxx),(boxy)

              IF feld[x].box = 1 THEN DRAWSPRITE 1, (boxx),(boxy)

              IF feld[x].box = 2 THEN DRAWSPRITE 2, (boxx),(boxy)

              IF feld[x].box = 3 THEN DRAWSPRITE 3, (boxx),(boxy)

  NEXT
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//mausbewegung
MOUSESTATE mx, my, b1, b2
DRAWSPRITE 20, mx, my
//mausbewegung ende


 SHOWSCREEN
WEND

///Ende Hauptschleife
ich glaub auf jeden fall muss von oben ja eins nachrutschen, sonst wird ja immer wieder das farblose von ganz oben runterrutschen.
es zeichnet irgendwie alle felder mit feld
  • .box = 0 voll................................plz help

nicht elegant, aber sowas könnte oder müsste ja da irgendwo rein.......nur funktioniert es bei mir nicht richtig.

Code (glbasic) Select
IF feld[1].box = 0 THEN feld[1].box = (RND(3)+1)
IF feld[2].box = 0 THEN feld[2].box = (RND(3)+1)
IF feld[3].box = 0 THEN feld[3].box = (RND(3)+1)
IF feld[4].box = 0 THEN feld[4].box = (RND(3)+1)
IF feld[5].box = 0 THEN feld[5].box = (RND(3)+1)
IF feld[6].box = 0 THEN feld[6].box = (RND(3)+1)
IF feld[7].box = 0 THEN feld[7].box = (RND(3)+1)
IF feld[8].box = 0 THEN feld[8].box = (RND(3)+1)
IF feld[9].box = 0 THEN feld[9].box = (RND(3)+1)
IF feld[10].box = 0 THEN feld[10].box = (RND(3)+1)

Kitty Hello

Also... ein 2-dimensionales Feld eindimensional abzubilden halte ich für ziemlichen Unfug. Warum!?
Das kostet nur Rechenzeit + Kopfscmerzen. Wri progammieren doch  nicht in FORTRAN.

Mach ein 2D-Feld und dann geht mein Code so wie er ist. Copy+Paste.

x-tra

ich hatte es ja erst 2d und da hieß es doch dann 1d würde besser gehen wegen den types.aber okay ich machs wieder 2d

Kitty Hello

1D geht besser, wenn du die 2. Dimension in dem Type realisierst, weil Du dann Zeilen schnell tauschen kannst. Willst Du aber nicht.
Für Bejeweled is ein klassisches 2D Feld ideal.

x-tra

[mal ein großes edit]

wir habens wieder mal fast um 3 Nachts, und ich poste hier mal nen aktuellen stand, aber nicht wundern, in der SUB "Movement" hauts wohl noch garnicht hin....

Nur meine Konzentration läßt langsam nach, und vielleicht erbarmt sich ja einer meiner, und hilft mir den code zu vervollstöndigen, dass er auch läuft.

so, nun schaut her:


Code (glbasic) Select
// --------------------------------- //
// Project: aqua
// Start: Tuesday, April 01, 2008
// IDE Version: 5.204
SETSCREEN 600, 600, 0
LIMITFPS 25
GOSUB variablen
GOSUB initdim
GOSUB material
GOSUB initfeld

WHILE TRUE
GOSUB statik
GOSUB movement
SHOWSCREEN
WEND

///Ende Hauptschleife


// ------------------------------------------------------------- //
// ---  VARIABLEN  ---
// ------------------------------------------------------------- //
SUB variablen:
GLOBAL TileSize = 50
GLOBAL tilesX = 10
GLOBAL tilesY = 10
GLOBAL randy = 50
GLOBAL randx = 49


ENDSUB // VARIABLEN




// ------------------------------------------------------------- //
// ---  INITDIM  ---
// ------------------------------------------------------------- //
SUB initdim:

             TYPE Tinfo
             posx
             posy

             box
             boxalt
             posyalt
             ENDTYPE

             GLOBAL  feld[] AS Tinfo



 DIM feld[tilesX][tilesY]



ENDSUB // INITDIM




// ------------------------------------------------------------- //
// ---  MATERIAL  ---
// ------------------------------------------------------------- //
SUB material:
LOADSPRITE "pfeil.png",20
LOADSPRITE "box1.png",1
LOADSPRITE "box2.png",2
LOADSPRITE "box3.png",3
LOADSPRITE "box5.png",5
LOADSPRITE "box6.png",6
LOADSPRITE "box7.png",7
LOADSPRITE "boxclear.png",4
LOADBMP "hintergrund.bmp"


ENDSUB // MATERIAL




// ------------------------------------------------------------- //
// ---  INITFELD  ---
// ------------------------------------------------------------- //
SUB initfeld:
FOR x = 0 TO tilesX-1
  FOR y = 0 TO tilesY-1
    feld[x][y].box = (RND(5)+1)
    WHILE ( y>1 AND feld[x][y-1].box = feld[x][y].box AND feld[x][y-2].box = feld[x][y].box) OR ( x>1 AND feld[x-1][y].box = feld[x][y].box AND feld[x-2][y].box = feld[x][y].box)
      feld[x][y].box = (RND(5)+1)
    WEND
  NEXT
NEXT
FOR x = 0 TO tilesX-1
 FOR y = 0 TO tilesY-1
 GLOBAL feld[x][y].posx = ((x*TileSize)+randx)
 GLOBAL feld[x][y].posy = ((y*TileSize)+randy)
 NEXT
NEXT

ENDSUB // INITFELD


// ------------------------------------------------------------- //
// ---  STATIC  ---
// ------------------------------------------------------------- //
SUB statik:

FOR x = 0 TO tilesX-1
FOR y = 0 TO tilesY-1

MOUSESTATE mx, my, b1, b2
DRAWSPRITE 20, mx, my
feld[x][y].boxalt = feld[x][y].box

IF y > 0
 feld[x][y-1].boxalt = feld[x][y-1].box
 feld[x][y-1].posyalt = feld[x][y-1].posy
ENDIF
IF b1 = 1
   IF mx >= feld[x][y].posx AND mx <= (feld[x][y].posx + 48) AND  my >= feld[x][y].posy AND my <= (feld[x][y].posy + 48)
    feld[x][y].box = 0
    feld[x][y-1].box = 0
ENDIF
ENDIF





IF feld[x][0].box = 0
     feld[x][0].box = (RND(5)+1)
ENDIF


              IF feld[x][y].box = 0 THEN DRAWSPRITE 4, feld[x][y].posx,feld[x][y].posy

              IF feld[x][y].box = 1 THEN DRAWSPRITE 1, feld[x][y].posx,feld[x][y].posy

              IF feld[x][y].box = 2 THEN DRAWSPRITE 2, feld[x][y].posx,feld[x][y].posy

              IF feld[x][y].box = 3 THEN DRAWSPRITE 3, feld[x][y].posx,feld[x][y].posy

              IF feld[x][y].box = 4 THEN DRAWSPRITE 5, feld[x][y].posx,feld[x][y].posy

              IF feld[x][y].box = 5 THEN DRAWSPRITE 6, feld[x][y].posx,feld[x][y].posy

              IF feld[x][y].box = 6 THEN DRAWSPRITE 7, feld[x][y].posx,feld[x][y].posy

PRINT mx, 10, 20
PRINT my, 10, 30



NEXT
NEXT

ENDSUB // STATIC




// ------------------------------------------------------------- //
// ---  MOVEMENT  ---
// ------------------------------------------------------------- //
//SUB movement:
FOR x = 0 TO tilesX-1
 FOR y = 0 TO tilesY-1
  IF y > 0
   IF feld[x][y].box = 0 AND  feld[x][y-1].box = 0
     feld[x][y-1].posyalt = feld[x][y-1].posyalt + 1
     DRAWSPRITE feld[x][y].boxalt, feld[x][y-1].posx, feld[x][y-1].posyalt
       IF feld[x][y-1].posyalt = feld[x][y].posy          
           feld[x][y].box = feld[x][y-1].boxalt            
        ENDIF              
             
   ENDIF              
  ENDIF
 NEXT
NEXT
//ENDSUB // MOVEMENT
ich weiß, die beiden letzten subs könnte man sicher zusammenfassen, aber der übersicht halber, vorerst einfach durchzusehen.

hoffe jemandem fällt was dazu ein....