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 / [DBP] Tic-Tac-Toe help

Author
Message
StaticBase
11
Years of Service
User Offline
Joined: 23rd Nov 2013
Location: Future
Posted: 23rd Nov 2013 18:48 Edited at: 23rd Nov 2013 23:33
Welcome to my first forum post and my first program ever! Don't you feel lucky? I've set my sights on programming a tic-tac-toe game and hell bent on seeing this through to the end.

My first step was to draw a typical grid for the game, composed of four separate lines. Each line covers the same distance and the length is based on screen size. This is so the grid may adapt to various machines. The position of each line revolves around the center of the screen.

Here is my logic behind this visually:



And below you will find my drawGrid() finction

StaticBase
11
Years of Service
User Offline
Joined: 23rd Nov 2013
Location: Future
Posted: 23rd Nov 2013 23:53
On to the next part - I want this game to rely on mouse input. In fact, I will not settle for any other option. I literally figured out how to use the for .. next loop a half an hour ago and scanning through some of DBPro's help files I chose to fill each space in the grid with a box (keeping the whole game 2-dimensional still). I figure later on I can use these boxes to detect whether or not my mouse cursor is hovering and/or clicking on any of the given spaces.

So the following function draws these boxes. The boxes are intended to be transparent and completely invisible but I have neither figured out how to do that yet nor do I desire that at the moment, for debugging purposes:


Here's another visual:
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Nov 2013 13:47
Quote: "function drawGrid()
function printBoard()"

FUNCTION is used to declare a function, if you want to call the function just type the name and parameters in brackets.

BOX is a faster drawing command than LINE: since LINE has to be able to draw in any direction it requires more calculations. To use BOX to draw straight lines you will need to give the box at least one pixel width or it wont display, I've done this for you and stored the width in a variable incase you want to scale it with the rest of the board.

All the variables declared inside your function can be constants, they will not change while the program is running, so they don't have to be inside the function where they will be initialized over and over again each time the function is called.



Formerly OBese87.

Login to post a reply

Server time is: 2024-11-23 15:15:08
Your offset time is: 2024-11-23 15:15:08