Variable issues
Answered
- Need more info
- Answered
- Working on it
in
Programming Questions
•
7 months ago
I recently got bored at work and (as I'm only just learning) decided to screw around and make a tic tac toe game. I got partway done when i realized i didn't set up variables to make it easier to place the player symbols (X and O). upon setting it up though i tried to set it like so:
int x1=width/3;
int x2=(width/3)*2;
int y1=height/3;
int y2=(height/3)*2;
I had until then, written out these numbers in full in the line placement for the board, and for the x and y placement of the player symbols. However, upon setting up these variables and switching them in, it destroyed the whole board. It treats width and height as 0 when they are used in variables like this. When I tried finding out if it actively changed the number, I then used the variable as a size for an ellipse to test and it used the previous size instead of the width/2 that i had requested. I set the screen to size(800,800); and also tried using float instead of int to see if it changed anything.
I am just unsure as to why these are not numbers that can be used for anything or why those functions have abandoned me.
1