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.

Dark GDK / Tic Tac Toe

Author
Message
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 25th Oct 2009 22:27
Sorry I just got DarkGDK today and I know I'm probably doing something very stupid but I'm having a little difficulty. I'm trying to make Tic Tac Toe (I've made it before in C++ but I lost the code and haven't touched C++ in years) and DarkBASIC but for some reason this array isn't storing data properly. I'm sorry if this is a n00bish question. Just trying to get my head round it.



The problem is that it isn't just [1][0] that's storing the value, it is also making a cross at [0][1] and [0][2]. Is there something stupid I'm doing here?

Also for some reason before you mouse over the grid some of the lines look too thick (the ones from top right to bottom left look 2 pixels wide instead of one) but as soon as the mouse enters the grid it resolves this issue itself.

Thanks

"A West Texas girl, just like me"
-Bush
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 25th Oct 2009 22:38
when you declare arrays you put the actual size of the array. what you have done is made a 2X2 grid instead of a 3X3 grid. but you do have it right when you are accessing it.

I am not smart. I am not powerful. I am just a guy. I am strengthened through my faith.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 25th Oct 2009 23:34
I thought arrays started from 0? so a 3x3 grid would be [2][2] as each array access-y thing can be [0],[1] or [2]. I did put [3][3] at first but thought it would be easier to code using [2][2].

"A West Texas girl, just like me"
-Bush
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 25th Oct 2009 23:59 Edited at: 26th Oct 2009 00:00
When you declare an array the size should be the actual size you want. So in your case when you declare the array you would declare it with the size of 3 but when you make references to it in your code the max size would be 2 and the first value would be 0.

Your bedtime story is scaring everyone
If found my very own Fail!: http://cheezburger.com/View.aspx?aid=2712171776
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 26th Oct 2009 05:25 Edited at: 26th Oct 2009 05:27
Ah right thanks. I've just hopped on over from DarkBASIC to give this a try and there an array declared dim Array1(2,2) would let you use anything up to and including 2. Thanks for that.

Edit: Hmm... Now it's just in a different wrong place. I have one at (1,0) but also one at (2,0). It's probably something glaringly obvious, but I can't figure it.

"A West Texas girl, just like me"
-Bush
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 26th Oct 2009 05:40
One other thing i notice is that you dont set the values in any of the spots of your array except for [1][0], which means that the other spots are most likeley being filled with some garbage number. I would suggest using a couple loops to populate the array with 0's. This may help.

I am not smart. I am not powerful. I am just a guy. I am strengthened through my faith.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 26th Oct 2009 05:51 Edited at: 26th Oct 2009 05:57
OK Even weirder the circles work fine:



(circle function from http://forum.thegamecreators.com/?m=forum_view&t=158250&b=22&p=0)


EDIT: You were right. How odd. I assumed that unless otherwise declared, variables were 0. That wouldn't explain why the circles weren't affected if it was just completely random numbers. Or would it. Oh well thanks for the help mate you're a legend I had no idea what was going on there.





Still showing 2 crosses/circles offset by about a pixel until I move the mouse cursor over the grid though... No idea what's causing that.

"A West Texas girl, just like me"
-Bush
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 26th Oct 2009 06:23
What is happening is that the calls to dbLine(), which should make a single pixel line, are actually making a 2 pixel line. I played with the empty circle code and it looks like only one line now, only thicker than the X. If dbDot() works on your comp, I would suggest replacing each call to dbLine() with a call to dbDot() in PlotCirclePoints(), using the first pair of coordinates as what youre passing. if not, then you can just use my fix:


ps, i dont know whats making the cross/circle offset, cause its not doin it for me.

I am not smart. I am not powerful. I am just a guy. I am strengthened through my faith.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 26th Oct 2009 13:06
dbDot() doesn't work. I'll have a proper play around later though. Cheers.

"A West Texas girl, just like me"
-Bush

Login to post a reply

Server time is: 2024-10-01 16:42:47
Your offset time is: 2024-10-01 16:42:47