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.

DarkBASIC Professional Discussion / Darkbasic pro game programming second edition

Author
Message
ashino
15
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 22nd Nov 2010 13:00
Hello,

I'm using "DarkBasic pro game programming second edition" book for information, i reached chap 9 the imageShuffle program, i want to ask about the code of this program at P.206, the are a group of numbers at first, so what do they represent? the book says "tile position data for calculating valid moves" but i can't understand what the numbers mean

‘ Tile position data for calculating valid moves
DATA 2,5,0,0
DATA 1,3,6,0
DATA 2,4,7,0
DATA 3,8,0,0
DATA 1,6,9,0
DATA 2,5,7,10
DATA 3,6,8,11
DATA 4,7,12,0
DATA 5,10,13,0
DATA 6,9,11,14
DATA 7,10,12,15
DATA 8,11,16,0
DATA 9,14,0,0
DATA 13,10,15,0
DATA 14,16,11,0
DATA 12,15,0,0
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Nov 2010 15:04
DATA will store a string of data in memory, usually placed right at the bottom of the program. This is then accessed further up in the program using restore and read. The data as it is right now is useless without the rest of the program. We need the whole program to see what exactly it represents.

Also note that most of us here did not learn DBP by reading a book, but rather just went through online tutorials, which you will find in the stickies on top of every board, or like me just played around with the code until getting a hang of it.

I recommend the tutorials, they are incredibly well written by people with over 6 years of expirience with DBP.

TheComet

ashino
15
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 22nd Nov 2010 15:28
I think i will do like you, read the code one more time and play with it maybe i will understand what are these numbers, I use the books so that I won't miss important details about the language and programming and then when i look for tutorials i would understand what's going on

thanx for the tips TheComet
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Nov 2010 16:00
Quote: "or like me just played around with the code until getting a hang of it."

Me too...

DBProUser
15
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 23rd Nov 2010 19:04 Edited at: 23rd Nov 2010 19:05
it is not so hard to understand. The Numbers represent the Tile-Position and the Valid Moves.

For Example the First Data-Command to read:
DATA 2,5,0,0

You can Move Tile Number one to Position 2 and 5, the 0 are Invalid Moves.

Tile Number Two:
DATA 1,3,6,0

You can slide TIle Number two to Positon One (left), Three (right) or Six (down) the 0 is the upper Border.

I hope i could help

P.S.
I wrote a tile-Game with a Array and a Swap-Function, then you don't need the Sometimes Confusing Data-Commands. Just a hint if you want to try on your own.
ashino
15
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 24th Nov 2010 08:59
Thanx DBProUser that was a great help, and your last note sounds much easier than using the data commands

Login to post a reply

Server time is: 2026-07-21 12:49:15
Your offset time is: 2026-07-21 12:49:15