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 / is there a way to match colours?

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 17th Feb 2008 19:38
I was just wondering how you would go about getting to object to register that they are next to each other under cirtain conditions
for example lets say we have :-

|green| |Yellow| |green|

and you then moved them to:-
|Yellow| |green| |green|

how would you go about making a program recognise that two of the same colour were touching?

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Feb 2008 20:25
You would use an array and put values into the array when you place the block in position - since at that point, you know both pieces of information.

When you want to know the colours or the blocks, access the array.

When blocks change places, update the array.

TDK_Man

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 17th Feb 2008 20:31
ah... i have no idea how to use arrays... never really used one before

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 17th Feb 2008 21:47
eh... never mind, i can't figure it out, i'm propbably just a little too thick to understand how it works, thanks for trying though

I can see from your smile, you're not here for the sunset.
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 17th Feb 2008 22:00
Quote: "eh... never mind, i can't figure it out, i'm propbably just a little too thick to understand how it works, thanks for trying though "

If you plan on doing anything more than easy with programming, you HAVE to learn arrays, might was well learn them now . What don't you understand about them?


Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 17th Feb 2008 22:14
the whole thing just confused me, it didn't make much sense to me at all, i understand that it holds the information in one small command rather than several but it doesn't help me understand how to use it

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Feb 2008 01:47
Did you actually read that tutorial which covers arrays? Because no-one is going to be able to explain them in any simpler way.

As Gil says, programming isn't a drag and drop thing - it's hard going at first.

It's a language and learning it is no different than learning Russian or Chinese. You'll get nowhere if you don't put any effort in.

Normally, the game you describe would only be achievable after months of learning - not the first week.

Learning how arrays work is essential and I think you need to aim a little lower and learn the beginners stuff first.

TDK_Man

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 18th Feb 2008 12:56
i know it's not that simple, i'm not an idiot, i have been messing about with programming in basic since the commodore 64, and all the languages vary so much, i have already made a small puzzle game so it's not like i'm a total noob at this stuff i have just never tried anything this complex before, yes i read the tutorial but i couldn't understand what it meant i know WHAT an array is, i just don't know how to read and write data from it and into it

I can see from your smile, you're not here for the sunset.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Feb 2008 04:15
Quote: " programming in basic since the commodore 64"

Quote: " never tried anything this complex before"


Umm, it's just arrays? I don't see how you could have programmed on a C64 yet can't grasp the concept of an array.


Define an array called 'stuff' that is capable of holding 10 elements of type integer:
dim stuff(10) as integer

To assign a value to one of the 10 possible elements:
stuff(7) = 42

And to print the value of one of the elements contained in the array:
print stuff(7)

If you had a variable called "thing#" that held that value of 56.5 then you would use array elements in all the same ways as you could use thing#, the only difference is the parenthesis and index number within the parenthesis which represents the element within the array you wish to retrieve.


Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 19th Feb 2008 14:04 Edited at: 19th Feb 2008 14:11
when i was playing with programming on the c64 i was 8....

anyway thank you thats more or less what i needed, seems to be a bit simpler to understand than the tutorial, i'm not saying the tutorial was bad, i just didn't understand it, maybe i'm a bit dumb but thank you.

So am i to understand then (from the tutorial and what is above) that if i wanted a "grid" of 10x10 i'd have an array like :

DIM stuff(10,10)

and if i wanted to write something to say 5th column second row it'd be like :

stuff(5,2)=69

and then of course to output it it would be

Print Stuff(5,2)

Seems so obvious now, i don't know why i couldn't figure it out from the tutorial.

I can see from your smile, you're not here for the sunset.
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 20th Feb 2008 18:10
yeah,
this is very useful post actually, i use arrays all the time in php etc but needed to know how to translate into db.
<mr burns>excellent</mr burns>
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 20th Feb 2008 18:11
check
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Feb 2008 18:43
Yeah - and color isn't needed the way you just said - you could just have "Types" Type 1 = All the red ones for example.

(OCnstants are good to know about for this - ... I THINK its #define CoinRed 1
#define CoinBlue 2

etc should work or something close.

Jeff032
17
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 22nd Feb 2008 19:35
#constant CoinRed 1
or
#constant CoinBlue = 2

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Feb 2008 19:45 Edited at: 22nd Feb 2008 19:45
No Equal [edit]Might be #DEFINE - look in help!

Login to post a reply

Server time is: 2024-09-27 10:31:13
Your offset time is: 2024-09-27 10:31:13