Topic:   Simple Rougelike project download   (Read 1818 times)


0 Members and 1 Guest are viewing this topic.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4408
    • View Profile
Re: Simple Rougelike project download
« Reply #15 on: August 14, 2020, 01:53:23 PM »
Looks like monPos is not a function, but an array. Is it a scope issue?

That makes a lot of sense, thanks Connors! I didn't realize SilverCreator arrays have the same syntax as functions.
Sorry for my confusion.

Johna100


  • GMG-er

  • **


  • Posts: 161

  • lalala
    • View Profile
Re: Simple Rougelike project download
« Reply #16 on: August 14, 2020, 07:15:05 PM »
renamed the monPos array and all the times it uses it to monsterPositionPlace.

TRY THIS


OPEN CARD

Code: [Select]
IF newLevel = 0 THEN
   LET newLevel = 1
   LET numberOfMon = 50
   
   LET toggleFirst = 0
   LET toggleSecond = 0
   
   LET scrolly = 0
   LET scrollx = 0
   
   DIM world$(10000)
   DIM tile$(10000)
   DIM colAmain(10000)
   DIM colBmain(10000)
   DIM colCmain(10000)
   DIM colA(10000)
   DIM colB(10000)
   DIM colC(10000)
   DIM monsterPositionPlace(numberOfMon)
   DIM monChar$(numberOfMon)
   DIM monColA(numberOfMon)
   DIM monColB(numberOfMon)
   DIM monColC(numberOfMon)
   DIM monName$(numberOfMon)
   DIM monLife(numberOfMon)
   DIM monAttack(numberOfMon)
   
   FOR a = 1 to 10000
      LET world$(a) = "#"
      LET colAmain(a) = 150
      LET colBmain(a) = 150
      LET colCmain(a) = 150
   NEXT
   
   LET roomsStart = 5550
   LET nextRoom = roomsStart
   
   FOR a = 1 to 18
      LET nextRoom = nextRoom - 1
      LET createFloory = nextRoom
      IF a = 6 THEN
         LET nextRoom = roomsStart
         LET nextRoom = nextRoom - 1
      END IF
      IF a = 12 THEN
         LET nextRoom = roomsStart
         LET nextRoom = nextRoom - 1
      END IF
      FOR b = 1 to 5
         IF toggleFirst > 0 THEN
            LET createFloory = createFloory + 100
            LET nextRoom = createFloory + 100
         END IF
         LET toggleFirst = 1
         LET createFloorx = createFloory
         LET nextRoom = createFloory
         FOR c = 1 to 5
            IF toggleSecond > 0 THEN
               LET createFloorx = createFloorx + 1
               LET nextRoom = nextRoom + 1
            END IF
            LET toggleSecond = 1
            IF createFloorx > 100 THEN
               IF createFloorx < 9900 THEN
                  LET world$(createFloorx) = "."
                  LET colAmain(createFloorx) = 150
                  LET colBmain(createFloorx) = 150
                  LET colCmain(createFloorx) = 150
               END IF
            END IF
         NEXT
      NEXT
      LET hallDir = RANDOM(4)
      LET createHall = nextRoom
      FOR d = 1 to 22
         IF hallDir = 1 THEN
            LET createHall = createHall + 1
            LET nextRoom = nextRoom + 1
         END IF
         IF hallDir = 2 THEN
            LET createHall = createHall - 1
            LET nextRoom = nextRoom - 1
         END IF
         IF hallDir = 3 THEN
            LET createHall = createHall + 100
            LET nextRoom = nextRoom + 100
         END IF
         IF hallDir = 4 THEN
            LET createHall = createHall - 100
            LET nextRoom = nextRoom - 100
         END IF
         
         IF createHall > 100 THEN
            IF createHall < 9900 THEN
               
               LET world$(createHall) = "."
               LET colAmain(createHall) = 150
               LET colBmain(createHall) = 150
               LET colCmain(createHall) = 150
            END IF
         END IF
      NEXT
     
   NEXT
   
   
   
   // PLACE MONSTERS
   
   FOR monPlacer = 1 to numberOfMon
     
      LET monsterPositionPlace(monPlacer) = RANDOM(10000)
      IF world$(monsterPositionPlace(monPlacer)) = "." THEN
         LET RND = RANDOM(3)
         IF RND = 1 THEN
            LET monChar$(monPlacer) = "g"
            LET monColA(monPlacer) = 150
            LET monColB(monPlacer) = 70
            LET monColC(monPlacer) = 70
            LET monName$(monPlacer) = "Goblin"
            LET monLife(monPlacer) = 22
            LET monAttack(monPlacer) = 9
         END IF
         IF RND = 2 THEN
            LET monChar$(monPlacer) = "s"
            LET monColA(monPlacer) = 70
            LET monColB(monPlacer) = 70
            LET monColC(monPlacer) = 150
            LET monName$(monPlacer) = "Snake"
            LET monLife(monPlacer) = 12
            LET monAttack(monPlacer) = 7
         END IF
         IF RND = 3 THEN
            LET monChar$(monPlacer) = "r"
            LET monColA(monPlacer) = 150
            LET monColB(monPlacer) = 70
            LET monColC(monPlacer) = 150
            LET monName$(monPlacer) = "Rat"
            LET monLife(monPlacer) = 5
            LET monAttack(monPlacer) = 4
         END IF
         
      END IF
   NEXT
   
   LET scrolly = scrolly - 360
   LET scrollx = scrollx - 290
   LET playerPos = 5550
   LET posYcounter = 10
   LET posXcounter = 10
END IF

FOR b = 1 to 10000
   LET colA(b) = colAmain(b)
   LET colB(b) = colBmain(b)
   LET colC(b) = colCmain(b)
   LET tile$(b) = world$(b)
NEXT

LET colA(playerPos) = 420
LET colB(playerPos) = 420
LET colC(playerPos) = 420
LET tile$(playerPos) = "P"

FOR a = 1 to numberOfMon
   
   LET monRNDmove = RANDOM(4)
   IF monsterPositionPlace(a) > 100 THEN
     
      IF monRNDmove = 1 THEN
         LET monsterPositionPlace(a) = monsterPositionPlace(a) - 100
         
         IF tile$(monsterPositionPlace(a)) = "#" THEN
            LET monsterPositionPlace(a) = monsterPositionPlace(a) + 100
         END IF
         
      END IF
     
      IF monRNDmove = 2 THEN
         LET monsterPositionPlace(a) = monsterPositionPlace(a) - 1
         
         IF tile$(monsterPositionPlace(a)) = "#" THEN
            LET monsterPositionPlace(a) = monsterPositionPlace(a) + 1
         END IF
         
      END IF
     
   END IF
   
   
   
   IF monsterPositionPlace(a) < 9900 THEN
     
      IF monRNDmove = 3 THEN
         LET monsterPositionPlace(a) = monsterPositionPlace(a) + 1
         
         IF tile$(monsterPositionPlace(a)) = "#" THEN
            LET monsterPositionPlace(a) = monsterPositionPlace(a) - 1
         END IF
         
      END IF
     
     
     
      IF monRNDmove = 4 THEN
         LET monsterPositionPlace(a) = monsterPositionPlace(a) + 100
         
         IF tile$(monsterPositionPlace(a)) = "#" THEN
            LET monsterPositionPlace(a) = monsterPositionPlace(a) - 100
         END IF
         
      END IF
     
   END IF
   
   
   LET colA(monsterPositionPlace(a)) = monColA(a)
   LET colB(monsterPositionPlace(a)) = monColB(a)
   LET colC(monsterPositionPlace(a)) = monColC(a)
   LET tile$(monsterPositionPlace(a)) = monChar$(a)
NEXT

CLEAR
PRINT "Press the spacebar key, type lower level then press the enter key to go to the next floor down"
PRINT " "

FOR a = 1 to numberOfMon
   
   IF playerPos = monsterPositionPlace(a) THEN
     
      LET life = life - monAttack(a)
      LET monLife(a) = monLife(a) - attack
     
      PRINT monName$(a) + " attacked you"
      PRINT "Your life is now " + STR$(life)
     
      PRINT "You Attacked " + monName$(a) + " for " + STR$(attack)
     
   END IF
   
NEXT




« Last Edit: August 14, 2020, 07:31:09 PM by Johna100 »