Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Silverwind

Pages: 1 ... 10 11 [12]
166
GameMaker / Gonna hang myself over this glitch...
« on: September 01, 2008, 04:38:18 AM »
I started making a simple Hang Man game last night, but now I'm stumped on a peculiar glitch. I think a repeat loop isn't repeating the correct amount of times. It seems to always repeat twice, even though it should repeat an amount of times equal to the length of the "sentence$" string variable.

Here's the source: http://www.mediafire.com/?o8dgyuqkzah

And here's the code: (this is the entire game's code. I've highlighted the area I think the glitch occurs in)

PICT CurrentCard

REPEAT
  sentence$ = USERASK Enter the name of a movie or book:
  sentence$ = UCASE$ sentence$
  block = 0
  IF sentence$ = "" THEN block = 1
  IF sentence$ = " " THEN block = 1
  IF sentence$ CONTAINS "." THEN block = 1
  IF sentence$ CONTAINS "," THEN block = 1
  IF sentence$ CONTAINS "/" THEN block = 1
  IF sentence$ CONTAINS "?" THEN block = 1
  IF sentence$ CONTAINS "'" THEN block = 1
  IF sentence$ CONTAINS ";" THEN block = 1
  IF sentence$ CONTAINS ":" THEN block = 1
  IF block = 0 THEN
    EXIT REPEAT
  ELSE
    ALERT The sentence must only contain letters and numbers.
  END IF
END REPEAT

blank$ = "_"
debug$ = ""
charactercheck$ = ""
characterchecknumber = 1
sentencelength = LEN sentence$
REPEAT
  charactercheck$ = MID$ sentence$ characterchecknumber 1
  IF charactercheck$ = " " THEN
    debug$ = debug$ + charactercheck$
  ELSE
    debug$ = debug$ + blank$
  END IF
  characterchecknumber = characterchecknumber + 1
  IF characterchecknumber > sentencelength THEN EXIT REPEAT
END REPEAT
PRINT $sentence$$ (length test)
PRINT
PRINT $debug$$ (length test)


ON KEYDOWN
  guess = 0
  keydown$ = UCASE$ keydown$
  IF keydown$ = "A" THEN guess = 1
  IF keydown$ = "B" THEN guess = 1
  IF keydown$ = "C" THEN guess = 1
  IF keydown$ = "D" THEN guess = 1
  IF keydown$ = "E" THEN guess = 1
  IF keydown$ = "F" THEN guess = 1
  IF keydown$ = "G" THEN guess = 1
  IF keydown$ = "H" THEN guess = 1
  IF keydown$ = "I" THEN guess = 1
  IF keydown$ = "J" THEN guess = 1
  IF keydown$ = "K" THEN guess = 1
  IF keydown$ = "L" THEN guess = 1
  IF keydown$ = "M" THEN guess = 1
  IF keydown$ = "N" THEN guess = 1
  IF keydown$ = "O" THEN guess = 1
  IF keydown$ = "P" THEN guess = 1
  IF keydown$ = "Q" THEN guess = 1
  IF keydown$ = "R" THEN guess = 1
  IF keydown$ = "S" THEN guess = 1
  IF keydown$ = "T" THEN guess = 1
  IF keydown$ = "U" THEN guess = 1
  IF keydown$ = "V" THEN guess = 1
  IF keydown$ = "W" THEN guess = 1
  IF keydown$ = "X" THEN guess = 1
  IF keydown$ = "Y" THEN guess = 1
  IF keydown$ = "Z" THEN guess = 1
  IF guess = 1 THEN
    guess$ = keydown$
    IF guessed$ CONTAINS guess$ THEN guess = 0
    guessed$ = guessed$ + guess$
  END IF

  IF guess = 1 THEN
    debug$ = ""
    charactercheck$ = ""
    characterchecknumber = 1
    sentencelength = LEN sentence$

    REPEAT
      charactercheck$ = MID$ sentence$ characterchecknumber 1
      IF charactercheck$ = " " THEN
        debug$ = debug$ + charactercheck$
      ELSE
        IF guessed$ CONTAINS charactercheck$ THEN
          debug$ = debug$ + charactercheck$
        ELSE
          debug$ = debug$ + blank$
        END IF
      END IF
      characterchecknumber = characterchecknumber + 1
      IF characterchecknumber > sentencelength THEN EXIT REPEAT
    END REPEAT

    CLEAR TEXT
    PRINT $sentence$$ (length test)
    PRINT
    PRINT $debug$$ (length test)
  END IF

  IF debug$ = sentence$ THEN
    ALERT You Win!
    GOTOCARD 2
  END IF
END KEYDOWN

167
GameMaker / Old glitch in GM resurfaced...
« on: April 08, 2008, 04:35:27 AM »
Looks like the that glitch that hampered progress on Gridz has resurfaced. The command line under a repeat block doesn't get read if there's too much code in the card script. I've highlighted the line that doesn't get read:


CLEAR TEXT
PICT enemypict

'     Don't change this code. It only activates when the player enters this card from outside of battle.

IF battlelock = 0 THEN
  battlelock = 1
  MOVIE 0 0 Data:Encounter.wav
  SPRITE 17 -500 -500 Data:Enemy Attack Marker.gif
  SPRITE 16 -500 -500 Data:Enemy Attack Marker.gif
  markerX = 50
  markerY = 226
  selectedbutton = 1
  SPRITE 2 140 225 Buttons.gif
  SPRITE 1 markerX markerY Marker.gif
  BplayerY = 93
  BplayerX = -39
  BenemyY = 93
  BenemyX = 313
  SPRITE 15 BplayerX BplayerY $playersprite$$
  SPRITE 14 BenemyX BenemyY $NPCsprite$$
  REPEAT 33
    BplayerX = BplayerX + 4
    BenemyX = BenemyX - 4
    SPRITE 15 BplayerX BplayerY
    SPRITE 14 BenemyX BenemyY
  END REPEAT

  test = 0

  playerhitalert = 0
  playermissalert = 0
  healalert = 0
  nopotionsalert = 0
  escapealert = 0
  enemyhitalert = 0
  enemymissalert = 0
  IF bossbattle = 1 THEN
    MOVIE 0 0 Data:Boss Battle Music.mp3
    LOOP MOVIE
  ELSE
    MOVIE 0 0 Data:Battle Music.mp3
    LOOP MOVIE
  END IF
END IF
'------------------------------------------------------------------------------------------------
SPRITE 15 BplayerX BplayerY
SPRITE 14 BenemyX BenemyY
SPRITE 2 140 225
SPRITE 1 markerX markerY

CLEAR TEXT
PRINT $playername$$ HP: $playerHP$
PRINT $enemyname$$ HP: $enemyHP$
PRINT
IF playerhitalert = 1 THEN PRINT You hit the enemy for $playerhit$ damage!
IF playermissalert = 1 THEN PRINT Your attack misses the enemy.
IF healalert = 1 THEN PRINT You restore $healamount$ HP. You have $ITEMhealingpotion$ Potions left.
IF nopotionsalert = 1 THEN PRINT You don't have any Potions.
IF escapealert = 1 THEN PRINT You couldn't escape...
IF enemyhitalert = 1 THEN PRINT The enemy hits you for $enemyhit$ damage!
IF enemymissalert = 1 THEN PRINT The enemy's attack misses you.
PRINT

playerhitalert = 0
playermissalert = 0
healalert = 0
nopotionsalert = 0
escapealert = 0
enemyhitalert = 0
enemymissalert = 0

ON TIMER 25
  IF blinkmarker = 0 THEN
    blinkmarker = 1
    markerX = markerX + 10
    SPRITE 1 markerX markerY
  ELSE
    blinkmarker = 0
    markerX = markerX - 10
    SPRITE 1 markerX markerY
  END IF
END TIMER

ON KEYDOWN
  upmove = 0
  downmove = 0
  IF selectedbutton = 1 THEN upmove = 1
  IF selectedbutton = 3 THEN downmove = 1

  IF keydown$ = "UPARROW" THEN
    IF upmove = 0 THEN
      selectedbutton = selectedbutton - 1
      IF selectedbutton < 1 THEN selectedbutton = 1
      markerY = markerY - 29
      SPRITE 1 markerX markerY
    END IF
  END IF
  IF keydown$ = "DOWNARROW" THEN
    IF downmove = 0 THEN
      selectedbutton = selectedbutton + 1
      IF selectedbutton > 3 THEN selectedbutton = 3
      markerY = markerY + 29
      SPRITE 1 markerX markerY
    END IF
  END IF

  IF keydown$ = "a" THEN
    IF selectedbutton = 1 THEN GOTOCARD 16
    IF selectedbutton = 2 THEN GOTOCARD 15
    IF selectedbutton = 3 THEN GOTOCARD 14
  END IF
END KEYDOWN


This is the card script of the player's turn in battle.

EDIT:

It's just occurred to me that the glitch may have returned due to a change Al made in 3.9.9a, which I don't think Al has released yet. Could someone test it in 3.9.9?

168
GameMaker / Very bewildering problem with the Scrolling V6...
« on: August 16, 2008, 04:09:52 PM »
I'm not sure if this is a glitch in GM or not, but it has brought a temporary halt to development on the Scrolling V6 Nav. Here's the file: http://www.mediafire.com/?sharekey=41bf6bec539742b7d2db6fb9a8902bda

The problem:
After colliding with an obstacle and moving in a non-opposite direction, (as in, left or right if the previous move direction was up) the computer changes the values of gridX and gridY accordingly to accommodate for the player moving onto the new space, but the code for scrolling the background sprite isn't executed. It's altogether baffling.

The keydown code is on card 2, and is the following:
Code: [Select]
ON KEYDOWN
  newtile$ = "empty"
  directionkeypressed = 0
  IF keydown$ = "UPARROW" THEN moveY = gridY - 1
  IF keydown$ = "DOWNARROW" THEN moveY = gridY + 1
  IF keydown$ = "LEFTARROW" THEN moveX = gridX - 1
  IF keydown$ = "RIGHTARROW" THEN moveX = gridX + 1
  IF keydown$ CONTAINS "ARROW" THEN directionkeypressed = 1
'----GET COLLISION CLASS OF NEW LOCATION--------------------------------------------------------
'  roomX = 1
'  roomY = 1
'  IF moveX > 7 THEN roomX = roomX + 1
'  IF moveX > 14 THEN roomX = roomX + 1
'  IF moveY > 7 THEN roomY = roomY + 1
'  IF moveY > 14 THEN roomY = roomY + 1
'  room = 3 * roomY
'  room = room - 3
'  room = room + roomX
'  IF room = 1 THEN gridlayout$ = gridlayout1$
'  IF room = 2 THEN gridlayout$ = gridlayout2$
'  IF room = 3 THEN gridlayout$ = gridlayout3$
'  IF room = 4 THEN gridlayout$ = gridlayout4$
'  IF room = 5 THEN gridlayout$ = gridlayout5$
'  IF room = 6 THEN gridlayout$ = gridlayout6$
'  IF room = 7 THEN gridlayout$ = gridlayout7$
'  IF room = 8 THEN gridlayout$ = gridlayout8$
'  IF room = 9 THEN gridlayout$ = gridlayout9$
  moveXY = 7 * moveY
  moveXY = moveXY - 7
  moveXY = moveXY + moveX
  IF roomY > 1 THEN moveXY = moveXY - 49
  IF roomY > 2 THEN moveXY = moveXY - 49
  IF roomX > 1 THEN moveXY = moveXY - 7
  IF roomX > 2 THEN moveXY = moveXY - 7
  newtile$ = MID$ gridlayout$ moveXY 1

  IF newtile$ = "" THEN newtile$ = "empty"
  IF newtile$ = "0" THEN newtile$ = "empty"
  IF newtile$ = "1" THEN newtile$ = "wall"
  IF newtile$ = "2" THEN newtile$ = "portal 1"
'---/GET COLLISION CLASS OF NEW LOCATION-------------------------------------------------------
'----COLLISION CLASSES--------------------------------------------------------------------------
  IF moveY < 1 THEN
    ALERT You're trying to move north.
'    gridY = 21
'    GOTOCARD northcard
  END IF
  IF moveY > 21 THEN
    ALERT You're trying to move south.
'    gridY = 1
'    GOTOCARD southcard
  END IF
  IF moveX < 1 THEN
    ALERT You're trying to move west.
'    gridX = 21
'    GOTOCARD westcard
  END IF
  IF moveX > 21 THEN
    ALERT You're trying to move east.
'    gridX = 1
'    GOTOCARD eastcard
  END IF
  IF newtile$ = "portal 1" THEN
'    gridY = moveY
'    gridX = 6
'    GOTOCARD portalcard
  END IF

  IF newtile$ = "empty" THEN
    gridX = moveX
    gridY = moveY
'     Position background sprite.
    IF keydown$ = "UPARROW" THEN bgY = bgY + 44
    IF keydown$ = "DOWNARROW" THEN bgY = bgY - 44
    IF keydown$ = "LEFTARROW" THEN bgX = bgX + 44
    IF keydown$ = "RIGHTARROW" THEN bgX = bgX - 44
'     Position NPC1sprite.
    NPC1spriteY = NPC1gridY * 44
    NPC1spriteY = NPC1spriteY - 44
    NPC1spriteY = NPC1spriteY + bgY
    NPC1spriteX = NPC1gridX * 44
    NPC1spriteX = NPC1spriteX - 44
    NPC1spriteX = NPC1spriteX + bgX
'     Position NPC2sprite.
    NPC2spriteY = NPC2gridY * 44
    NPC2spriteY = NPC2spriteY - 44
    NPC2spriteY = NPC2spriteY + bgY
    NPC2spriteX = NPC2gridX * 44
    NPC2spriteX = NPC2spriteX - 44
    NPC2spriteX = NPC2spriteX + bgX
'     Position NPC3sprite.
    NPC3spriteY = NPC3gridY * 44
    NPC3spriteY = NPC3spriteY - 44
    NPC3spriteY = NPC3spriteY + bgY
    NPC3spriteX = NPC3gridX * 44
    NPC3spriteX = NPC3spriteX - 44
    NPC3spriteX = NPC3spriteX + bgX
'     Position NPC4sprite.
    NPC4spriteY = NPC4gridY * 44
    NPC4spriteY = NPC4spriteY - 44
    NPC4spriteY = NPC4spriteY + bgY
    NPC4spriteX = NPC4gridX * 44
    NPC4spriteX = NPC4spriteX - 44
    NPC4spriteX = NPC4spriteX + bgX
  IF newtile$ = "wall" THEN
    moveX = gridX
    moveY = gridY
  END IF
'---/COLLISION CLASSES--------------------------------------------------------------------------
'     Check which NPCs are alive and draw the sprites of the living ones.
  IF NPC1alive = 1 THEN SPRITE -11 NPC1spriteX NPC1spriteY $NPC1sprite$$
  IF NPC2alive = 1 THEN SPRITE -12 NPC2spriteX NPC2spriteY $NPC2sprite$$
  IF NPC3alive = 1 THEN SPRITE -13 NPC3spriteX NPC3spriteY $NPC3sprite$$
  IF NPC4alive = 1 THEN SPRITE -14 NPC4spriteX NPC4spriteY $NPC4sprite$$
  SPRITE 1 bgX bgY
END KEYDOWN

169
GameMaker / 4.0 Progress?
« on: May 12, 2008, 09:47:44 AM »
How's 4.0 coming along Al? Any estimated release dates for screenshots or betas?

170
GameMaker / Click Area Glitch
« on: June 13, 2008, 08:27:17 AM »
That glitch where click areas occasionally resize to random proportions in the editor has returned. It's a real nuisance, as they often resize to so small a size that editing becomes impossible.

171
GameMaker / Simple New Inventory
« on: June 11, 2008, 05:31:36 PM »
I posted this in another topic, but I'm posting here so that everyone can find it easier. This is a simple inventory I came up with that stores item properties in arrays.

This is how to set the properties of weapons and armors. The first parameter in the array is the item's name, the second parameter is the Attack plus it gives in combat, and the third parameter is the Defence plus it gives in combat.
Code: [Select]
Weapon1Stats$ = "RustyDagger 10 0"
Weapon2Stats$ = "BattleAxe 14 0"
Weapon3Stats$ = "LongSword 20 0"

Armor1Stats$ = "LeatherVest 0 8"
Armor2Stats$ = "ChainMail 0 12"
Armor3Stats$ = "SpikedCuiras 3 17"

How to set the player's weapon/armor properties to those of another item: (in other words, how to equip an item ;) )
Code: [Select]
PlayerWeaponStats$ = Weapon1Stats$
PlayerArmorStats$ = Armor1Stats$

How to reference the properties of an item:
Code: [Select]
PlayerWeaponName$ = WORD$ PlayerWeaponStats$ 1
PlayerArmorName$ = WORD$ PlayerArmorStats$ 1

WeaponAttackPlus$ = WORD$ PlayerWeaponStats$ 2
ArmorAttackPlus$ = WORD$ PlayerArmorStats$ 2
WeaponAttackPlus = VAL WeaponAttackPlus$
ArmorAttackPlus = VAL ArmorAttackPlus$
WeaponDefencePlus$ = WORD$ PlayerWeaponStats$ 3
ArmorDefencePlus$ = WORD$ PlayerArmorStats$ 3
WeaponDefencePlus = VAL WeaponDefencePlus$
ArmorDefencePlus = VAL ArmorDefencePlus$

Attack = Attack + WeaponAttackPlus
Attack = Attack + ArmorAttackPlus
Defence = Defence + WeaponDefencePlus
Defence = Defence + ArmorDefencePlus

It's fairly straight forward. You shouldn't have to edit any of the code to use it, so you don't even have to understand it. All you have to do is set the values of "Weapon1Stats" "Weapon2Stats" and so on. If you do understand it however, you could add extra parameters to the arrays such as attribute bonuses or durability. Or even the item's sell price. :) It's easy to mod.

172
GameMaker / Secret PRINT Command Property?
« on: May 23, 2008, 07:16:41 AM »
I was upgrading Al's Text Adventure Template to fix a glitch where the length of the TypeText$ variable isn't always correct, (causing problems with the DELETE command) and I discovered that the ; mark at the end of a PRINT command causes the next PRINT command to print on the previous line. That's a really useful feature! :D

Are there any more secret command properties in GM Al?

173
GameMaker / Why 255?
« on: June 03, 2008, 02:39:47 AM »
What technical reason governs the max length of string variables? Can variables in 4.0 contain larger values?

174
Code Exchange / [GM] V6 Grid Navigation
« on: May 11, 2009, 08:24:30 AM »
Here's the latest V6 template: http://www.mediafire.com/?di1yn88cy84565v

175
Code Exchange / [GM] Arrays
« on: February 17, 2010, 07:15:01 PM »
I was puzzling over how to manage treasure chests in the Roguesoft RPG Engine when I came to the regrettable conclusion that I'd have to use arrays. This bothered me, as the only method I could think up involved FILEIO and I didn't want players tampering with saves.

I suddenly remembered an article Al wrote some time ago and hurried online to read it. Sure enough, Al solved the puzzle ages ago, and the only limitation is consistent value length.

I've rewritten his marvelous routines in my own syntax and swapped the value length from 2 to 1. Here they are should anyone find them useful:

Create an array:
Code: [Select]
arrayName$ = "ABC"

Copy the value of an item to the "itemValue$" variable:
Code: [Select]
'--- Get an item's value.
USERASK Which item do you want to get the value of?
item = val userask$
itemValue$ = mid$ array$ item 1

Change an item's value:
Code: [Select]
'--- Select an item in the array.
USERASK Which item will you assign a new value to?
item = val userask$
itemToLeft = item - 1
itemToRight = item + 1

'--- Designate a new value for the item.
newItemValue$ = USERASK Set the item's new value:

'--- Reconstruct the array with the item's new value.
itemsToLeft$ = left$ array$ itemToLeft
IF item =< 1 THEN itemsToLeft$ = ""
itemsToLeft$ = itemsToLeft$ + newItemValue$
itemsToRight$ = mid$ array$ itemToRight
newArrayValue$ = itemsToLeft$ + itemsToRight$
array$ = newArrayValue$

And check out Al's original article for 2 char length item values: http://gamemakersgarage.com/index.php?cat=articles&id=9

EDIT:

I've updated the above code to fix an incorrect operator. Also, here's a source example: http://www.mediafire.com/?imtn2nz22u4

Pages: 1 ... 10 11 [12]