Tileset movement

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Tileset movement

Post by JosepM » Fri Apr 26, 2013 7:17 am

Hi,

I trying to test a horizontal or vertical tiles movement when the user move the player.
Any experiencie doing that?
My idea is load from a xml a matrix with the whole x,y and tile type composition and assign to a transparent buttons. The player move into the maze and collect treasures. As he move up or down or left or right, the maze must move on sync with the player.
Into the updatescreen repositionate the maze walls after the player movement.

Example of tiles that I want use for.
http://graphicriver.net/item/2d-game-ti ... thor=flipz

Have sense? other better way to that?

Salut,
Josep M

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Location: Thailand
Contact:

Re: Tileset movement

Post by dave_probertGA6e24 » Fri Apr 26, 2013 8:23 am

Hi Joseph,

That makes sense. Are you planning on the character being able to move within the screen, or are they fixed in the centre and the screen moves around them?

If they are fixed then it might become a bit slow doing the refresh if they are moving a lot, though the player will always know where the character is.

If the tiles are small and you keep some limits on the areas the character can go then doing a drawing refresh when the character moves over a screen 'edge' (a couple of tiles in from the actual edge is best) for a 'free' character movement type (better for exploration type game)

Hope that helps a bit.
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: Tileset movement

Post by JosepM » Fri Apr 26, 2013 11:33 am

Hi Dave,

Yes, the idea is that when the player reach any of the edges the tiles will be moved.

My thoughts are on how deal with enemies movements, bullets and events.

Two ways to focus on.

1. Create a matrix of "transparents" buttons and assign to each the image ID and use custom properties to check events, intersections...
The player and enemies move over this buttons.


2. Positionate X,Y for each of the elements, for example walls, doors, treasures, gold coins... over the scene.

Where in the updatescreen check the intersects with the walls?
The tiles are 16x16 pixels.

Thoughts?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Tileset movement

Post by BvG » Fri Apr 26, 2013 12:56 pm

That should work fine I have made a similar code for showing a strategy game map.

First I make sure to have all the data, In my case i use an array[x,y] type of grid storage. Then I have a preset grid of buttons, that resizes together with the stack. When I need an update of the map, I have a function that gets the topleft map position to show (for example 5,29) as well as the width and height of the current "viewport". It then loops trough the buttons and assigns the correct id, querried from the contents of the array[x,y]. It's a pretty trivial calculation (untested, nonworking example code) :

Code: Select all

global myMap
put 5 into xMap
put 29 into yMap
put 12 into myWidth
put 20 into myHeight

repeat with x = 1 to myWidth
   repeat with y = 1 to myHeight
      set the icon of button "tile" && (x,y) to myMap[xMap + x, yMap + y]
   end repeat
end repeat
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Location: Thailand
Contact:

Re: Tileset movement

Post by dave_probertGA6e24 » Fri Apr 26, 2013 2:55 pm

Movement and checking wall collisions can be done in many ways - depending on the detail you want in the game.

You could have the character move from 'square' to 'square' (ie centre to centre over the grid) which would mean that you only need to flag which 'squares' are actually walls and not allow the character to go into them. This is like the old RPG-Maker (Japanese RPG) games do. It makes it very simple to handle the map and all collisions, etc. You simply have a large matrix (array) with multiple 'layers' with data for each cell.
eg. (very rough concept)
for a map location 100,200
map[100][200]['base'] = 'grass'
map[100][200]['item'] = 1234 // an item id

and a wall near it:
map[102][200]['base'] = 'rocks'
map[102][200]['wall'] = true

If you are going to have the character move with pixel accuracy then the easiest way to handle this (that I know of) is to make some invisible overlays with 2-bit png's (a colour and transparent). With these you can use the "intersect()" function checking for "opaque pixels" (if that is fixed on LC 6.0.1 ?). These extra tiles would be invisible to the player but the computer will still be able to check them.

Thing to remember about this is to forward check the intersect before actually showing the movement (so you can ignore the move if the is invalid). It's a much more complex way to do the character movement checks, but does look better when done correctly.

I too am working on a top-down RPG style game, but with bigger tiles and a randomly generated map. It's still at the early-ish stage - but uses many of the concepts talked about here.

Hope that helps,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Post Reply

Return to “Games”