Topic:   [GM] V6 Grid Navigation   (Read 74994 times)


0 Members and 4 Guests are viewing this topic.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
[GM] V6 Grid Navigation
« on: May 11, 2009, 08:24:30 AM »
Here's the latest V6 template: http://www.mediafire.com/?di1yn88cy84565v
« Last Edit: December 21, 2010, 02:24:51 PM by Silverwind »
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: [GM] V6 Grid Navigation
« Reply #1 on: August 04, 2009, 05:19:08 PM »
I noticed the working example link was broken so I've updated it. I also improved the NPC template and added the revamped Roguesoft logo to the main menu screen.

btw, is the template easy enough to understand? As in, do you feel you could use it in your games?
I survived the spammage of 2007

HarryCaray


  • GMG-er

  • **


  • Posts: 119

  • I love YaBB 1G - SP1!
Re: [GM] V6 Grid Navigation
« Reply #2 on: August 04, 2009, 08:46:36 PM »
Looky looky:

Clicky clicky

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: [GM] V6 Grid Navigation
« Reply #3 on: August 05, 2009, 01:46:55 AM »
Wow, now that's streamlined! Ah, but old Silver knows his grid navs... the lowest I can get it in GM is 23 lines:

Card Script
Code: [Select]
gridMap$ = "1111111100000110000011000001100000110000011111111"
playerSpriteX = 137
playerSpriteY = 137
SPRITE 1 playerSpriteX playerSpriteY Player 1.gif

Keydown
Code: [Select]
ON KEYDOWN
  playerNewSpriteX = playerSpriteX
  playerNewSpriteY = playerSpriteY
  IF keydown$ = "UPARROW" THEN playerNewSpriteY = playerSpriteY - 44
  IF keydown$ = "DOWNARROW" THEN playerNewSpriteY = playerSpriteY + 44
  IF keydown$ = "LEFTARROW" THEN playerNewSpriteX = playerSpriteX - 44
  IF keydown$ = "RIGHTARROW" THEN playerNewSpriteX = playerSpriteX + 44
  playerNewGridY = playerNewSpriteY / 44
  playerNewGridX = playerNewSpriteX / 44
  playerNewGridX = playerNewGridX + 1
  playerNewGridY = playerNewGridY + 1
  playerNewGridXY = 7 * playerNewGridY
  playerNewGridXY = playerNewGridXY - 7
  playerNewGridXY = playerNewGridXY + playerNewGridX
  playerTile$ = MID$ gridMap$ playerNewGridXY 1
  IF playerTile$ = "0" THEN playerSpriteX = playerNewSpriteX
  IF playerTile$ = "0" THEN playerSpriteY = playerNewSpriteY
  SPRITE 1 playerSpriteX playerSpriteY
END KEYDOWN

I'm not particularly fond of the streamlined versions however, as they only handle the bare minimum of features.
I survived the spammage of 2007

HarryCaray


  • GMG-er

  • **


  • Posts: 119

  • I love YaBB 1G - SP1!
Re: [GM] V6 Grid Navigation
« Reply #4 on: August 05, 2009, 05:59:21 PM »
But its so very easy to add to it. Adding door support is almost as easy as just adding a method.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: [GM] V6 Grid Navigation
« Reply #5 on: August 07, 2009, 03:36:14 PM »
Here's an example of what can be done with a little tinkering:

Giant player sprites. The only difference to the code is the "playerSize" variable in the player property block, and the "giant sprite" collision routine. If you set "playerSize" to 1, collision will be calculated as normal. If you set it to 2, collision will be detected on a 4x4 tile radius.
Code: [Select]
' --- Edit these vars to set the attributes of the grid.
gridMap$ = "1000001100000010000101000000100100010000001000001"
gridSize = 7
tileSize = 44

' --- Edit these vars to set the attributes of the player.
playerSprite$ = "Giant Spider.gif"
playerGridX = 1
playerGridY = 1
playerMoveSpeed = 16
playerSize = 2


' --- Determine the player's sprite coordinates based on its grid coordinates.
playerSpriteY = playerGridY * tileSize
playerSpriteY = playerSpriteY - tileSize
playerSpriteY = playerSpriteY + 5
playerSpriteX = playerGridX * tileSize
playerSpriteX = playerSpriteX - tileSize
playerSpriteX = playerSpriteX + 5
SPRITE 1 playerSpriteX playerSpriteY $playerSprite$$

'------------------------------------------------------------------------------------------------

ON KEYDOWN
  playerNewGridX = playerGridX
  playerNewGridY = playerGridY

  ' --- Check which direction the player wants to move in.
  IF keydown$ = "UPARROW" THEN playerNewGridY = playerGridY - 1
  IF keydown$ = "DOWNARROW" THEN playerNewGridY = playerGridY + 1
  IF keydown$ = "LEFTARROW" THEN playerNewGridX = playerGridX - 1
  IF keydown$ = "RIGHTARROW" THEN playerNewGridX = playerGridX + 1

  ' --- Check what kind of tile the player is trying to move onto. (check if it's traversable or not)
  playerNewGridXY = 0
  playerNewGridXY = gridSize * playerNewGridY
  playerNewGridXY = playerNewGridXY - gridSize
  playerNewGridXY = playerNewGridXY + playerNewGridX
  playerTile$ = MID$ gridMap$ playerNewGridXY 1
  IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
  IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
  IF playerNewGridX < 1 THEN playerTile$ = "Obstacle"
  IF playerNewGridX > gridSize THEN playerTile$ = "Obstacle"
  IF playerNewGridY < 1 THEN playerTile$ = "Obstacle"
  IF playerNewGridY > gridSize THEN playerTile$ = "Obstacle"

  ' --- Calculate collision for giant sprites.
  IF playerSize = 2 THEN

    IF keydown$ = "UPARROW" THEN
      IF playerTile$ = "Empty Tile" THEN
        playerNewGridXY2 = playerNewGridXY + 1
        playerTile$ = MID$ gridMap$ playerNewGridXY2 1
        IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
        IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
      END IF
    END IF

    IF keydown$ = "DOWNARROW" THEN
      IF playerTile$ = "Empty Tile" THEN
        playerNewGridXY2 = playerNewGridXY + gridSize
        playerTile$ = MID$ gridMap$ playerNewGridXY2 1
        IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
        IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
      END IF
      IF playerTile$ = "Empty Tile" THEN
        playerNewGridXY2 = playerNewGridXY2 + 1
        playerTile$ = MID$ gridMap$ playerNewGridXY2 1
        IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
        IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
      END IF
    END IF

    IF keydown$ = "LEFTARROW" THEN
      IF playerTile$ = "Empty Tile" THEN
        playerNewGridXY2 = playerNewGridXY + gridSize
        playerTile$ = MID$ gridMap$ playerNewGridXY2 1
        IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
        IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
      END IF
    END IF

    IF keydown$ = "RIGHTARROW" THEN
      IF playerTile$ = "Empty Tile" THEN
        playerNewGridXY2 = playerNewGridXY + 1
        playerTile$ = MID$ gridMap$ playerNewGridXY2 1
        IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
        IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
      END IF
      IF playerTile$ = "Empty Tile" THEN
        playerNewGridXY2 = playerNewGridXY2 + gridSize
        playerTile$ = MID$ gridMap$ playerNewGridXY2 1
        IF playerTile$ = "0" THEN playerTile$ = "Empty Tile"
        IF playerTile$ = "1" THEN playerTile$ = "Obstacle"
      END IF
    END IF

    IF playerNewGridX < 1 THEN playerTile$ = "Obstacle"
    IF playerNewGridX = gridSize THEN playerTile$ = "Obstacle"
    IF playerNewGridY < 1 THEN playerTile$ = "Obstacle"
    IF playerNewGridY = gridSize THEN playerTile$ = "Obstacle"
  END IF

  ' --- If the tile has no obstacles on it, move the player onto the tile.
  IF playerTile$ = "Empty Tile" THEN
    playerGridX = playerNewGridX
    playerGridY = playerNewGridY
  END IF

  ' --- Determine the player's sprite coordinates based on its grid coordinates.
  playerSpriteY = playerGridY * tileSize
  playerSpriteY = playerSpriteY - tileSize
  playerSpriteY = playerSpriteY + 5
  playerSpriteX = playerGridX * tileSize
  playerSpriteX = playerSpriteX - tileSize
  playerSpriteX = playerSpriteX + 5
  SPRITEPATH 1 playerSpriteX playerSpriteY playerMoveSpeed

  CLEAR TEXT
  PRINT keydown$: $keydown$$
  PRINT playerNewGridXY: $playerNewGridXY$
  PRINT playerNewGridXY2: $playerNewGridXY2$
  PRINT playerTile$: $playerTile$$
  PRINT
  PRINT playerNewGridX: $playerNewGridX$
  PRINT playerNewGridY: $playerNewGridY$
END KEYDOWN
I survived the spammage of 2007

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: [GM] V6 Grid Navigation
« Reply #6 on: December 05, 2009, 10:16:20 AM »

Quote
I'm not particularly fond of the streamlined versions however, as they only handle the bare minimum of features.
i agree, so how bout we streamline a system with features, who can get the least amount of lines?

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: [GM] V6 Grid Navigation
« Reply #7 on: December 05, 2009, 01:29:56 PM »
Sure! How about traveling to neighbouring rooms, teleporters and dialogue invokers?
I survived the spammage of 2007

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
« Last Edit: December 15, 2009, 12:24:43 PM by EqwanoX »

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: [GM] V6 Grid Navigation
« Reply #9 on: December 15, 2009, 08:57:23 PM »
Quote
V7's out ;D

http://www.silvercreator.net/cgi-bin/yabb2/YaBB.pl?num=1260901384/0#0
Wow thats amazing! (I wonder if thats possible with gm) [thinks] (probably but it would run very slowly I would imagine)
EDIT: Well heres my shot at V7 with GM (I used imagefile with overlay) Click Here
« Last Edit: December 15, 2009, 10:07:37 PM by Tireas_Dragon »
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: [GM] V6 Grid Navigation
« Reply #10 on: December 16, 2009, 09:56:32 AM »
 it loaded a few trees but it didnt seem to work for me.

whats gms sprite limit? cause sc v7 uses over 80 sprites. i suppose you could load the ground texture (like grass) as one large sprite so it only has to load the obstacle sprites

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: [GM] V6 Grid Navigation
« Reply #11 on: December 16, 2009, 04:55:17 PM »
I didn't use sprites I used imagefile. Did you enable imagefile command uses overlay. When I load it up it seems to be disabled I had to enable it twice. Its in game options.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: [GM] V6 Grid Navigation
« Reply #12 on: December 17, 2009, 03:53:10 AM »
Like Tireas said, go to Game Options in the Go menu and make sure "IMAGEFILE command overlays" is checked. It works correctly if you do that. For some reason the uploaded file had it disabled.

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: [GM] V6 Grid Navigation
« Reply #13 on: December 19, 2009, 08:24:12 PM »
it works now, this is a good port, nice work

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: [GM] V6 Grid Navigation
« Reply #14 on: December 31, 2009, 02:22:43 PM »
Ah, but subsisto panton! While that's certainly a very impressive routine for handling map decor I can't help but notice that the method for handling collision detection remains entirely the same as V6, and I feel it necessary to remind you that the V in the V series has up until present referred to the version number of the navigation engine alone and not the additional routines used in conjunction with it. I therefore must regrettably inform you that I cannot concur in the recognition or existence of a V7 navigation engine.

Hoping this letter finds you in good health,

your old friend,

Doctor A. Van Helsing
« Last Edit: December 31, 2009, 02:23:32 PM by Silverwind »
I survived the spammage of 2007