Topic:   Help with SC testplay crashing   (Read 5573 times)


0 Members and 1 Guest are viewing this topic.

Johna100


  • GMG-er

  • **


  • Posts: 173

  • lalala
Help with SC testplay crashing
« on: June 03, 2020, 10:29:39 AM »
EDIT: I HAVE A NEW CODE THAT WORKS, SEE BELOW IN THE NEXT POST.


When I test my game and use the right key it quits.

Here is my code:

OPENCARD:
Quote
DIM world(9000)
DIM tile$(100)

FOR a = 1 to 9000
LET RND = RANDOM(3)
   LET world(a) = RND
NEXT

LET screenPos = 0


FOR a = 1 to 100
LET view = screenPos + a

   IF world(view) = 1 THEN
      LET tile$(a) = "."
   END IF
   IF world(view) = 2 THEN
      LET tile$(a) = "."
   END IF
   IF world(view) = 3 THEN
      LET tile$(a) = "T"
   END IF
NEXT


KEY DOWN:
Quote
IF RIGHTKEY = TRUE THEN
   LET screenPos = screenPos + 1
   GOTOCARD 1
END IF


PAINT:
Quote
FOR a = 1 to 10
   LET x = 0
   LET y = y + 20
   FOR b = 1 to 10
      LET x = x + 20
      LET tileNum = tileNum + 1
     
      SETPENCOLOR 255, 255, 255
      DRAWSTRING tile$(tileNum), x, y, "Arial", 12
     
   NEXT
NEXT
« Last Edit: June 06, 2020, 04:44:54 AM by Johna100 »

Johna100


  • GMG-er

  • **


  • Posts: 173

  • lalala
Re: Help with SC testplay crashing
« Reply #1 on: June 06, 2020, 04:42:53 AM »
I started over with a new code but the same idea. My game works by manually copy and paste the code instead of having a loop inside a loop.

HERE IS THE NEW CODE


OPENCARD:

Code: [Select]
DIM tile$(9000)
DIM colA(9000)
DIM colB(9000)
DIM colC(9000)

FOR a = 1 to 9000
   LET tile$(a) = ";"
   LET colA(a) = RANDOM(255)
   LET colB(a) = RANDOM(255)
   LET colC(a) = RANDOM(255)
NEXT

LET tile$(1) = "1"
LET tile$(2) = "2"



KEYDOWN:

Code: [Select]
IF RIGHTKEY = TRUE THEN
   LET screenPos = screenPos + 1
   GOTOCARD 1
END IF


PAINT:

Code: [Select]
LET tileNum = 0
LET ty = 40


LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT

LET ty = ty + 10
LET tx = 40
FOR a = 1 to 30
   LET tileNum = tileNum + 1
   LET tileNum = tileNum + screenPos
   LET tx = tx + 10
   SETPENCOLOR colA(tileNum), colB(tileNum), colC(tileNum)
   DRAWSTRING tile$(tileNum), tx, ty, "Courier", 15
NEXT




Johna100


  • GMG-er

  • **


  • Posts: 173

  • lalala
Re: Help with SC testplay crashing
« Reply #2 on: June 06, 2020, 06:55:20 AM »
I found a way to make it work without copy and paste the code. It turns out I had a strange adding of variables. That combined with a loop inside a loop would make it crash. Crash when you updated one of the variables by pressing a key.

HERE IS SOME CODE THAT HAS A LOOP INSIDE A LOOP AND DOES NOT CRASH


***NOTE that open game is in the Global Scripting***
OPEN GAME:

Code: [Select]
DIM tile$(90000)
DIM colA(90000)
DIM colB(90000)
DIM colC(90000)

FOR a = 1 to 90000
   LET RND = RANDOM(5)
   IF RND = 1 THEN
      LET tile$(a) = "."
      LET colA(a) = 70
      LET colB(a) = 220
      LET colC(a) = 70
   END IF
   IF RND = 2 THEN
      LET tile$(a) = "."
      LET colA(a) = 220
      LET colB(a) = 170
      LET colC(a) = 70
   END IF
   IF RND = 3 THEN
      LET tile$(a) = "f"
      LET colA(a) = 70
      LET colB(a) = 220
      LET colC(a) = 70
   END IF
   IF RND = 4 THEN
      LET tile$(a) = "T"
      LET colA(a) = 70
      LET colB(a) = 220
      LET colC(a) = 70
   END IF
   IF RND = 5 THEN
      LET tile$(a) = "S"
      LET colA(a) = 90
      LET colB(a) = 90
      LET colC(a) = 170
   END IF
   
NEXT


KEY DOWN:

Code: [Select]
IF UPKEY = TRUE THEN
   LET screenPos = screenPos - 30
   GOTOCARD 1
END IF

IF DOWNKEY = TRUE THEN
   LET screenPos = screenPos + 30
   GOTOCARD 1
END IF

IF RIGHTKEY = TRUE THEN
   LET screenPos = screenPos + 1
   GOTOCARD 1
END IF

IF LEFTKEY = TRUE THEN
   LET screenPos = screenPos - 1
   GOTOCARD 1
END IF


PAINT:

Code: [Select]
LET fontSize = 12
LET border = 40
LET tilePadding = 10

LET tileNum = 0
LET ty = border


FOR j = 1 to 30
   LET ty = ty + tilePadding
   LET tx = border
   FOR a = 1 to 30
      LET tileNum = tileNum + 1
      LET square = tileNum + screenPos
      LET tx = tx + tilePadding
      SETPENCOLOR colA(square), colB(square), colC(square)
      DRAWSTRING tile$(square), tx, ty, "Courier", fontSize
   NEXT
NEXT

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Help with SC testplay crashing
« Reply #3 on: June 27, 2020, 01:29:20 AM »
If you could upload here a project that shows the crashing then I would still like to look into it.

No projects should ever crash so I would like to fix that bug.

Johna100


  • GMG-er

  • **


  • Posts: 173

  • lalala
Re: Help with SC testplay crashing
« Reply #4 on: July 03, 2020, 01:11:57 AM »
The test play window closes when the array is lower or higher than the amount. I will get a file uploaded soon.