Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Matrix Movement in dBPro

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 9th Oct 2005 23:24
I am making a strategy rpg and was wondering if I could set the squares of a matrix to be individual tiles. Each character can move a certain number of tiles and once the character's game status is active, then all the possible movements for the character would be highlighted. I was wondering if this could be accomplished using dBPro solely?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Oct 2005 23:49
Yes it could be done, but the problem I think would be scale.

Unless your matrix is quite small, each matrix tile will probably be far too big. Depends on what you are doing.

TDK_Man

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 10th Oct 2005 00:23
umm... the matrix is


would that be too big? What do you mean it depends on what I am doing?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Oct 2005 03:34
Ah OK...

I thought you meant that you had like an RPG character on a landscape and he was standing on a matrix tile with a limited number of squares (tiles) available for him to move in each turn.

I assumed you were asking if the available moves could be displayed on the matrix by changing the textures temporarily.

This is possible because I used the method to highlight matrix tiles in MatEdit with the keyboard.

My size comment was regarding whether your matrix is a 'world' landscape which you walk around, or whether it was like the grid in a 'board' game that you looked down on like a chess board.

If it's a world matrix and stretches off far into the distance, it would have to be stretched considerably - making each tile square massive and therefore unsuitable for highlighting.

If your matrix is displayed like a chessboard view then yes it's perfectly possible - depending on exactly what you want.

What I mean by this is, is the move available like the queen in chess along a single line or freeform so you could go say two forwards and three to the right, with a 'totting up' system of squares?

TDK_Man

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 10th Oct 2005 04:22
What I mean is, every battle will take place on a 3-dimensional landscape that will be sectioned off into, 15x15 squares. There will be a chracter on the chessboard-like playing field, but only where the

At the beginning of the bout, the middle 3 squares on the bottom row and the middle 3 squares on the second to the bottom row will be highlighted as solid dark gray squares. Each of these squares can potentionally hold one of your units. You will move the cursor, which outlines each square that it is over, onto one of the 6 dark gray squares and press the select button and scroll through your available units and choose to recruit them. Once you recruit all of your units to the battlefield, the initial solid dark gray squares will revert back to their normal coloring (translucent with a white outlining) and the battle will begin.

When it is one of your unit's turn, depending on the speed of the unit, the cursor will automatically highlight the square that unit is currently occupying. If you choose to move your unit, you wlll select 'move' from the menu and all of the available squares will be highlighted as solid dark gray squares like during the recruitment process. When you select one of the squares, the unit will move to that square and another menu will come up in which all of the available actions will be displayed.

Once I fully figure out how they work, I believe I will be using functions. One for the battle process, and perhaps some for the menus, and some for the damage and experience points and what not. And perhaps algorithims.

I have trailed off of subject so, anyways, how would you go about coding a cursor and the dark gray squares?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Oct 2005 05:44
Create a couple of integer two-dimensional arrays:

Dim MatTexNorm(15,15)
Dim MatTexTemp(15,15)

These are sized the same as the tiles across and down of the matrix used.

Assuming that you have created a texture image containing all the tile images required for the battlefield, you should fill the MatTextNorm array with integers representing the tile numbers to texture the matrix in it's normal state - ie the tile pattern. The contents of this array is never altered.

Assuming you have used Prepare Matrix Texture, you can texture the matrix from this array in a nested loop whenever you want the matrix in it's original state.

Then copy the contents of the MatTexNorm array into the MatTexTemp array.

When you want to alter the existing tiles on the matrix to show possible moves, all your calculations should be aimed at altering the values in the MatTexTemp array.

Once you have altered the values in the MatTexTemp array, use it to re-tile the matrix. If you continuously use one array then the other in a loop, you can make it look like some tiles are flashing on and off.

When finished, you use the MatTexNorm array to restore the original tile pattern.

TDK_Man

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 10th Oct 2005 06:29
thanks chief, i'll try this out
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 11th Oct 2005 00:50 Edited at: 11th Oct 2005 00:53
reading this is kind of confusing (arrays are confusing in general). I would like to see a sample, or your code illustrated. The only thing i understand about arrays is that they are similar to grids.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Oct 2005 00:55
OK, I'll do an example for you if you read the array tutorial I did and let me know if it helped you understand them!

http://www.amtedit.com/db.htm

TDK_Man

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Oct 2005 02:02
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 11th Oct 2005 02:52 Edited at: 11th Oct 2005 03:03
damn you're good!!! gracias mi amigo! yo soy muy (whatever the hell appreciative is in Spanish). yes, i did read up on them, but i didn't really get anymore knowledge than i already had. one question though, why are there 3 gray tiles at either side of the board?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Oct 2005 07:54
Quote: "why are there 3 gray tiles at either side of the board"


Sorry - I had it in my mind that is what you asked for.

OK, just checked...

Quote: "At the beginning of the bout, the middle 3 squares on the bottom row and the middle 3 squares on the second to the bottom row will be highlighted as solid dark gray squares."


I misread that. It's easy enough to alter though.

Each one of the numbers in that 11x11 grid is a tile number from the texture image. There are 4 textures in the image, so you can only use numbers 1 to 4.

Simply edit the numbers to create the tile pattern you want, being careful not to alter the number of numbers if you see what I mean...

If you use a different size matrix, (say 15x15) then you will need to alter the DIMS so the arrays have 15x15 elements and add more numbers to the data statements so that there are 15 rows of 15 numbers.

Pretty straight forward really...

I guess that was what you were after then?

TDK_Man

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 13th Oct 2005 01:25 Edited at: 13th Oct 2005 01:33
Quote: "I guess that was what you were after then?"


In my game, when you begin a battle, the level is set up like a chess board. All of your enemies are on one side of the board, and 6 gray squares are on the other. The 6 gray squares each has the potential of holding one of your units. You will select a square and then select which of your units you want to put there. When you have selected all of your units, the 6 gray squares change back to the normal coloring and the fight begins.

I have another question... the characters in my game will be able to move a certain number of squares. If you choose the Move command and the unit's MOV stat is 2, then he will be able to move forward 2 squares, backward 2 squares, or left or right two squares. But, he can also move up 1 square and right or left 1 square and back 1 square and right or left 1 square. This is what I mean: x's are the terrain, and the o's are the gray/flashing areas.

xxxxxxxxxxxxxxxxxxxxxxx-------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx--------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx|ooooo|oooooo|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx|ooooo|oooooo|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx----------------------------------xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx|ooooo|ooooo| Your |oooooo|oooooo|xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx|ooooo|ooooo| Unit |oooooo|oooooo|xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx---------------------------------- xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx|ooooo|oooooo|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx|ooooo|oooooo|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx---------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx|oooooo|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx--------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Would this be possible?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 13th Oct 2005 06:21
ANYTHING is possible... as long as you know how to do it!

In this case you have a few options. The one I would go for is a 1x1 move limit method - provided that the moves are freeform and don't restrict players to specific patterns from the start square.

A brief outline:

1. Store how many squares in total the player can move in TotMoves.

2. Calculate where the player can move within one square of the current square and alter the array to light up those squares.

3. When the player moves onto one of these squares, deduct 1 from TotMoves, recalculate the new pattern in the array and highlight the new matrix pattern.

4. When TotMoves = 0 then that player camnnot move any more squares.

That's the easiest method I can think of anyway.

TDK_Man

Login to post a reply

Server time is: 2024-11-27 16:58:06
Your offset time is: 2024-11-27 16:58:06