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.

2D All the way! / Data Tutorial

Author
Message
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 2nd Apr 2004 11:25
Data can be used in loads of ways, but as a beginner Im having trouble understanding how to control where my program reads its data stamements from. PLease could somebody explain a bit about how to position the read head? If I have this:

data 101,104,209,099,888,734
data 202,657,362,345,765,631

how can I read the third piece of data on the second line? (362)

THis is just an example, and I want to ask more questions about it all later...

GIve me more power!
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Apr 2004 12:34 Edited at: 2nd Apr 2004 12:35
You read all of the data before the program starts. This turns it into a kind of Ghost Data. Then you can restore any part of it that you want to use using labels. Once read, it again becomes invisible.





Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 8th Apr 2004 04:33 Edited at: 8th Apr 2004 05:07
You'll have to read all of your data and store it. It looks like what you're asking for requires a multi dimensional array. If not, well I'll provide an example for a tile system. Using a 2D array so that you can access rows and colums of data.

Here's an example of how you might do that:



Now if you wanted to display the third tile over and the third tile down is then you would check map(3,3) and see that it's holding a 1.

It is possible to do what you requested, IF you use the restore command. Though, it's not a very efficient method of reading and accessing your data. Data statements are linear. You read them from beginning to end. Say you had a data statement that contained 10 items (ie. data 1,2,3,4,5,6,7,8,9,0). Now, you can't read 10th item without reading the first 9. Data statements don't work that way. However, if you read all 10 and you want to go back and read the 5th item, you can do that if you use the restore command and you read the first 5 items all over again. Not a very effective method at all. This is why you would store the data in an array.

Quote: " Timesoft - Your wife is death. How? NO idea.
But it is murder. REVENGE!!!!!!!!!"

Hands down the funniest synopsis for a game ever. All your base are belong to us!
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 8th Apr 2004 12:40
OK, thanks. I think Im beggining to understand it all...

It makes me think of the android from star trek:next generation. Do you think that when he wants to quote from a book, he has to read the whole book again up until the point where the quote is?Haha!



GIve me more power!
Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 11th Apr 2004 01:48
What where you using data for if you don't mind my asking. I might be able to help you futher.

Quote: " Timesoft - Your wife is death. How? NO idea.
But it is murder. REVENGE!!!!!!!!!"

Hands down the funniest synopsis for a game ever. All your base are belong to us!
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 11th Apr 2004 21:18
i would like to know what is data all about, where can i use it ? why? i dont get it, its data and memblock, the only two thinks i dont know about but everyone talks about it

I will make urban chaos 2, ive already concepted the story, its my dream, i wont to go to muky foot
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 11th Apr 2004 22:38
DATA's just a bunch of numbers in a list, seperated by commas. Like reading a file, but the file is already loaded.

Lotto numbers might be...
For Num = 1 to 2
for n = 1 to 6
Read LottoNo
Lotto(Num,n) = LottoNo
next n
next num

Data 24,32,34,39,41,44
Data 5,13,22,24,36,49

But mostly Data is used to make levels for games.

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 11th Apr 2004 22:48 Edited at: 11th Apr 2004 23:50
Quote: "i would like to know what is data all about, where can i use it ? why? i dont get it, its data and memblock, the only two thinks i dont know about but everyone talks about it"


Well, data is one of the most basic core elements of basic language programming. I would reccomend getting a book or doing some research on the internet.

Quote: "
DATA

DATA value[,value,...,value]

The DATA statement holds information that will fill variables in a READ statement. Any type of information can be stored here, separated by commas. If a comma, space, or color are to be used as data, they must be enclosed in quote marks("). Two commas with nothing in between will be read as zero, or an empty string.

Note: the information in brackets is optional.

The line containing the DATA statement doesn't actually have to be executed while running the program, so most programmers leave all the DATA statements at the end of the program, out of the way.


"


While I'm at it it's also worth mentioning the RESTORE statement.
Quote: "
RESTORE

RESTORE

BASIC maintains an internal pointer to the next DATA constant to be READ. This pointer can be reset to the first DATA constant in a program using the RESTORE statement. The RESTORE statement can be used anywhere in the program to begin re-READing DATA.


"

Appeared in:

Title:
VIC 20 Programmers Reference Guide

ISBN:
0-672-21948-4

Author:
A. Finkel, N. Harris, P. Higginbottom, and M. Tomczyk

Publisher:
Commodore Business Machine, Inc. and Howard W. Sams & Co., Inc.

First Printing:
1981

Quote: " Timesoft - Your wife is death. How? NO idea.
But it is murder. REVENGE!!!!!!!!!"

Hands down the funniest synopsis for a game ever. All your base are belong to us!

Login to post a reply

Server time is: 2025-05-14 03:29:57
Your offset time is: 2025-05-14 03:29:57