i know. Its been really hard. But i guess i will just try and do something else now.
Hidden_mistakes 0 Light Poster
:( thanks anyways. I really wish i could but ive got a week left to finish the whole game and my tutor didn't bother teaching us any C++ so it really has been a learn what you have to in the time you have class.
Hidden_mistakes 0 Light Poster
http://jnrdev.72dpiarmy.com/
Its the 3rd one- big maps and scrolling.
Thanks for taking the time to help me out :)
Hidden_mistakes 0 Light Poster
well if you look in the code the array values are not specified they are just x and y, which makes me believe that these coordinates are specified in the map file(linker address map) that i cannot open or view at all. I could be wrong as im not 100% as to what is happening in the code.
Hidden_mistakes 0 Light Poster
Ok so from what you have said it is dealing with this part in the code- however it only specifies x and y as its numbers. would these numbers be stored in the map file?
void CMap::loadMap(const char *file){
FILE *mapfile;
int i, j, t;
mapfile = fopen(file, "rb");
if(tiles) //map has already been initialized
freetiles();
fread(&width, sizeof(int), 1, mapfile); //read map width
fread(&height, sizeof(int), 1, mapfile); //read map height
tiles = new int[width*height]; //get memory for the map
t = 0;
for(j = 0; j < width; j++){
for(i = 0; i < height; i++){
fread(&tiles[t], sizeof(int), 1, mapfile); //read tile
t++;
}
}
fclose(mapfile);
tiles2d = new int*[height]; //build 2d index array to map data
for(i=0; i<height; i++){
tiles2d[i] = &(tiles[i*width]); //tiles[i] is a pointer to tile row i
}
}
void CMap::draw(){
int x, y; //screen coord for current tile
int mx, my; //current tile map coord
int sx = 0-(scroll_x%TILESIZE); //startx
int smx = (sx+scroll_x)/TILESIZE; //starty
for( y = 0-(scroll_y%TILESIZE), my = (y+scroll_y)/TILESIZE; y < 480; y+=TILESIZE){
for( x = sx, mx = smx; x < 640; x+=TILESIZE){
if(tileset[ tiles2d[my][mx] ].spr != NULL)
tileset[ tiles2d[my][mx] ].spr->draw(x,y);
mx++;
}
my++;
}
}
Hidden_mistakes 0 Light Poster
Well that was helpful, Thanks.
Any chance you will share your knowledge? or else i don't see any reason for you to have posted on my thread.
Hidden_mistakes 0 Light Poster
I made a slideshow in dreamweaver which works, however when it gets to the end of the cycle it displays a black image before it loops again- how can i get this black 'image' to disappear?
In the header part:
<script type="text/javascript">
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs) {
var imageSeparator = imageFiles.indexOf(";");
var nextImage = imageFiles.substring(0,imageSeparator);
if (document.all) {
document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
document.getElementById(pictureName).filters.blendTrans.Apply();
}
document.getElementById(pictureName).src = nextImage;
if (document.all) {
document.getElementById(pictureName).filters.blendTrans.Play();
}
var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length) + ';' + nextImage;
setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
displaySecs*1000);
// Cache the next image to improve performance.
imageSeparator = futureImages.indexOf(";");
nextImage = futureImages.substring(0,imageSeparator);
if (slideCache[nextImage] == null) {
slideCache[nextImage] = new Image;
slideCache[nextImage].src = nextImage;
}
}
</script>
----------------------------------------------------------------------------------------------------------
In the body part: (class img = border:thin solid yellow; max-width:400px; padding:0;)
<table class="img" align="center">
<tr>
<td>
<img style="" id="foto" src="/images/opening/img01.jpg" height="240" width="306">
</td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
RunSlideShow("foto","/images/opening/img01.jpg;"
+ "/images/opening/img02.jpg;"
+ "/images/opening/img03.jpg;"
+ "/images/opening/img04.jpg;"
+ "/images/opening/img05.jpg;"
+ "/images/opening/img06.jpg;"
+ "/images/opening/img07.jpg;"
+ "/images/opening/img08.jpg;"
+ "/images/opening/img09.jpg;"
+ "/images/opening/img10.jpg;"
+ "/images/opening/img11.jpg;"
+ "/images/opening/img12.jpg",6);
</script>
Hidden_mistakes 0 Light Poster
I am trying to get a div to automatically cycle through images using dreamweaver. I have gotten one image to display but nothing happens after this. Can anyone see where i am going wrong?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="Assets/styles.css" rel="stylesheet" type="text/css" />
<script>
NewImg = new Array (
"images/1.jpg",
"images/2.jpg",
"images/3.jpg",
"images/4.jpg",
"images/5.jpg"
);
/* as many or few images and the path <strong class="highlight"><vb_highlight>to</strong></vb_highlight> them */
var ImgNum = 5;
var ImgLength = NewImg.length - 1;
var delay = 3000; /* Time delay between Slides in milliseconds */
var lock = false;
var run;
function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) { ImgNum = 0; }
if (ImgNum < 0) { ImgNum = ImgLength; }
document.getElementById('slideshow').src = NewImg[ImgNum];
}
}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}
</script>
</head>
<body>
<div id="Shell">
<div id="header">
<img src="Images/images%3A1.jpg" name="slideshow"><br>
<a href="images<b></b>:chgImg(-1)">Previous</a> |
<a href="images<b></b>:auto()">Auto/Stop</a> |
<a href="images<b></b>:chgImg(1)">Next</a>
</div>
Hidden_mistakes 0 Light Poster
Hi, So i am trying to make a racing game. I have found a code/website (http://www.gamedev.net/reference/articles/article735.asp)that explains collision detection. However i cannot figure out how to implement this in my code. If anyone could help me to do this i would be very grateful. If you need me to post my code i will but its quite long.
Hidden_mistakes 0 Light Poster
well all ive gotten so far is to get the image to appear on screen, but at the moment it is positioned at the top left next to the player and acts like the player does
Hidden_mistakes 0 Light Poster
That looks like what im looking for, i just wish i knew how to implement it into my code
Hidden_mistakes 0 Light Poster
I am trying to get my racing game to recognise when two images have hit eachother when this happens I then want the game to display "Player 1 or 2 wins" and then quit the game. My code is very long so i will not post unless i need to. Im am using visual C++ and have looked at other stuff on the net but cannot seem to find anything that helps.
Hidden_mistakes 0 Light Poster
I am making a racing game and am trying to find a way to let some one 'win' the game. in order to do this I am trying to display and image on the background at a certain position. This image isn't visable on the screen though until the racer looks around the background which moves. Once the racer finds this image i want the game to display "player _ wins" and then quit after 5 seconds. If you can help me with the image placement or the rest of it i would be grateful. I am using Visual C++ if that helps
Thanks
Hidden_mistakes 0 Light Poster
I am trying to move a player in direction angle by speed. I need to use trigonometric functions in order to calculate this. Can anyone help me discover how to do this?
if (playerB.up == true) {
(playerB.speed)+=((Delta*ballspeed)/1000);
}
if (playerB.down == true) {
(playerB.speed)-=((Delta*ballspeed)/1000);
}
if (playerB.left == true) {
(playerB.angle)-=((Delta*ballspeed)/1000);
}
if (playerB.right == true) {
(playerB.angle)+=((Delta*ballspeed)/1000);
}
//move player in direction angle by speed
Hidden_mistakes 0 Light Poster
Right, but no one else will learn anything by learning how to speed up your player - on a forum like this, ideally (at least in my opinion) the problem should be abstracted as far as possible so that it will help in as many cases as possible once it gets to the archives. So my point is, if someone helps you figure out how to get the hold down time of a key (a general thing), then it would be up to you to apply it to your specific problem (moving the player).
See what I mean?
Dave
Yes i see what you mean, however i don't really know C++ and would appreciate as much help as someone, who knows what they are doing, is willing to give.
Hidden_mistakes 0 Light Poster
Actually my question was how to speed the player up as stated in the topic header.
Hidden_mistakes 0 Light Poster
Hi i am trying to create a racing game and at the moment i have keyboard input which moves the player around at the same continous speed. I am wanting it to speed the player up however the longer you hold the key down for. Any simple way i can achieve this?
#include "SDL.h"
#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#pragma comment(lib,"Winmm.lib")
/* ---------------------------------------------------------------------- */
/* Defines/Enumerations */
/* ---------------------------------------------------------------------- */
#define SPEED 2
#define GAMETIME 30 //inactivity for 30s quits game
/* ---------------------------------------------------------------------- */
/* Type Declarations */
/* ---------------------------------------------------------------------- */
struct PLAYER
{
//SDL_Rect pos;
SDL_Surface *sprite;
Sint32 dir;
Sint32 life;
Sint32 score;
float by;
float bx;
float pos_y;
float pos_x;
bool up, right, left, down;
bool w, s, a, d;
};
struct BALL
{
//SDL_Rect pos;
SDL_Surface *sprite;
float bx, by;
float pos_x, pos_y;
};
/* ---------------------------------------------------------------------- */
/* Global Data */
/* ---------------------------------------------------------------------- */
/// The start time
SDL_Surface *SCREEN;
/// Some Sprites
SDL_Surface *background, *intro, *numbers;
PLAYER playerA, playerB;
BALL ball;
SDL_Joystick *joy0;
Uint32 iTicksLastKey=0; //inactivity counter
Uint32 TicksElapsed=0; //ticks elapsed since last update
Sint16 iMoveX;
Sint16 iMoveY;
Sint16 iMoveXOld; //for comparing the last value
Sint16 iMoveYOld;
float ballspeed=85; //ball speed, number of pixels ball travels in one second
SDL_Surface *level;
/* ---------------------------------------------------------------------- */
/* Helper */
/* ---------------------------------------------------------------------- */
void go();
/// Handle events
bool handleEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
{
switch(event.key.keysym.sym)
{
case SDLK_UP: { playerB.up = true; break; }
case SDLK_DOWN: { playerB.down = true; …
Hidden_mistakes 0 Light Poster
In the rect called levelrect i adjusted the width and the height which corected the right hand screen position.
levelrect.x=iRound(playerA.pos_x-SCREEN->w/28);//right hand side screen
levelrect.y=iRound(playerA.pos_y-SCREEN->h/10);
Hidden_mistakes 0 Light Poster
the code is a racing game that is controlled by key inputs, i am trying to get accleration aswel if anyone knows anything about that. The code was a pong game that was hacked into a racing game which is a split screen and the user controls the background to move a horse around a fair type thing. Im not sure what i can do to make it seem like a player(there are two) wins and therefore makes the game quit.
I am hoping for the horses to race to find the tent with the red flag on it, then display player "1" or "2" wins depending on who makes it there first. then after 3 seconds the game will quit. Is it possible for C++ to find a colour on the screen or do i need to think or something different?
Hidden_mistakes 0 Light Poster
I am trying to write a racing game but i need some winning conditions. Im not sure where to start, any pointers would help. Im using Visual C++
Hidden_mistakes 0 Light Poster
I am wondering why the right hand side of my split screen isn't in the middle and also why the game goes off of the background, any help would be much appreciated
#include "SDL.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#pragma comment(lib,"Winmm.lib")
/* ---------------------------------------------------------------------- */
/* Defines/Enumerations */
/* ---------------------------------------------------------------------- */
#define SPEED 2
#define GAMETIME 30 //inactivity for 30s quits game
/* ---------------------------------------------------------------------- */
/* Type Declarations */
/* ---------------------------------------------------------------------- */
struct PLAYER
{
//SDL_Rect pos;
SDL_Surface *sprite;
Sint32 dir;
Sint32 life;
Sint32 score;
float by;
float bx;
float pos_y;
float pos_x;
bool up, right, left, down;
bool w, s, a, d;
};
struct BALL
{
//SDL_Rect pos;
SDL_Surface *sprite;
float bx, by;
float pos_x, pos_y;
};
/* ---------------------------------------------------------------------- */
/* Global Data */
/* ---------------------------------------------------------------------- */
/// The start time
SDL_Surface *SCREEN;
/// Some Sprites
SDL_Surface *background, *intro, *numbers;
PLAYER playerA, playerB;
BALL ball;
SDL_Joystick *joy0;
Uint32 iTicksLastKey=0; //inactivity counter
Uint32 TicksElapsed=0; //ticks elapsed since last update
Sint16 iMoveX;
Sint16 iMoveY;
Sint16 iMoveXOld; //for comparing the last value
Sint16 iMoveYOld;
float ballspeed=85; //ball speed, number of pixels ball travels in one second
SDL_Surface *level;
/* ---------------------------------------------------------------------- */
/* Helper */
/* ---------------------------------------------------------------------- */
void go();
/// Handle events
bool handleEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
{
switch(event.key.keysym.sym)
{
case SDLK_UP: { playerB.up = true; break; }
case SDLK_DOWN: { playerB.down = true; break; }
case SDLK_LEFT: { playerB.left = true; break; }
case SDLK_RIGHT: { playerB.right = true; break; } …
Hidden_mistakes 0 Light Poster
I got it to work by using this code
PlaySound("beep.wav",NULL,SND_FILENAME|SND_ASYNC | SND_LOOP);
Thanks for your help
Hidden_mistakes 0 Light Poster
I got this piece of code
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#pragma comment(lib,"Winmm.lib")
int main(void)
{
PlaySound("file.wav",NULL,SND_FILENAME);
return 0;
}
But it will only play at the begining of the program where i want it to loop- how can i do this?
Hidden_mistakes 0 Light Poster
I am trying to get music to loop in the background of a game. However im really not sure how to do this. Can anyone give me a starting point please? I am using Visual C++ btw.
Hidden_mistakes 0 Light Poster
Hi i am hacking a pong game into a racing game. At the moment i am trying to blit to a half screen with player A on th right and B on the left. any one know why it isn't working? I am using Visual C++.
/* Pony Pong
#include "SDL.h"
#include <stdlib.h>
//#include <windows.h>
//using namespace std;
/* ---------------------------------------------------------------------- */
/* Defines/Enumerations */
/* ---------------------------------------------------------------------- */
#define SPEED 2
#define GAMETIME 30 //inactivity for 30s quits game
/* ---------------------------------------------------------------------- */
/* Type Declarations */
/* ---------------------------------------------------------------------- */
struct PLAYER
{
//SDL_Rect pos;
SDL_Surface *sprite;
Sint32 dir;
Sint32 life;
Sint32 score;
float by;
float bx;
float pos_y;
float pos_x;
bool up, right, left, down;
bool w, s, a, d;
};
struct BALL
{
//SDL_Rect pos;
SDL_Surface *sprite;
float bx, by;
float pos_x, pos_y;
};
/* ---------------------------------------------------------------------- */
/* Global Data */
/* ---------------------------------------------------------------------- */
/// The start time
SDL_Surface *SCREEN;
/// Some Sprites
SDL_Surface *background, *intro, *numbers;
PLAYER playerA, playerB;
BALL ball;
SDL_Joystick *joy0;
Uint32 iTicksLastKey=0; //inactivity counter
Uint32 TicksElapsed=0; //ticks elapsed since last update
Sint16 iMoveX;
Sint16 iMoveY;
Sint16 iMoveXOld; //for comparing the last value
Sint16 iMoveYOld;
float ballspeed=85; //ball speed, number of pixels ball travels in one second
SDL_Surface *level;
/* ---------------------------------------------------------------------- */
/* Helper */
/* ---------------------------------------------------------------------- */
void go();
/// Handle events
bool handleEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
{
switch(event.key.keysym.sym)
{
case SDLK_UP: { playerB.up = true; break; }
case SDLK_DOWN: { playerB.down = true; break; }
case SDLK_LEFT: …
Hidden_mistakes 0 Light Poster
Yes ok that is true- can i copy paste that sample code or do i need to change it? and if i need to change it how would i go about doing that?
thanks
Hidden_mistakes 0 Light Poster
so there is nothing i can just simply change or add that would fix this annoying issue? like i said new to java and its all just very mind boggling at the moment
Hidden_mistakes 0 Light Poster
ok so that makes sense- im really new to java so what part do i need to change so the X shows up? the new image icon or the mark part?
Hidden_mistakes 0 Light Poster
No sorry but i've played around with it a little more but now i can only get the O's to show up but no X's :( heres the code at the moment:
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class TicTacToe extends JPanel implements ActionListener
{
//Class constants how big ect the window will be
private static final int WINDOW_WIDTH = 400;
private static final int WINDOW_HEIGHT = 400;
private static final int TEXT_WIDTH = 10;
/*Sets up the a 3 by 3 playing grid used the supplied java help
to figure this out*/
private static final GridLayout Layout_Style = new GridLayout(3,3);
//Button and window-how the frame and buttons or squares should look
private JFrame window = new JFrame("TicTacToe");
private JButton Square1 = new JButton("");
private JButton Square2 = new JButton("");
private JButton Square3 = new JButton("");
private JButton Square4 = new JButton("");
private JButton Square5 = new JButton("");
private JButton Square6 = new JButton("");
private JButton Square7 = new JButton("");
private JButton Square8 = new JButton("");
private JButton Square9 = new JButton("");
ImageIcon mark = new ImageIcon("src/x.jpg");
boolean win = false;
public TicTacToe()
{
window.setSize(WINDOW_WIDTH,WINDOW_HEIGHT);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// exits the application once the game has been won
window.setLocationRelativeTo(null);//Centers the window
//Add to window the internet helped me to see what this should look like
window.getContentPane().setLayout(Layout_Style);
window.getContentPane().add(Square1);
window.getContentPane().add(Square2);
window.getContentPane().add(Square3);
window.getContentPane().add(Square4);
window.getContentPane().add(Square5);
window.getContentPane().add(Square6);
window.getContentPane().add(Square7);
window.getContentPane().add(Square8);
window.getContentPane().add(Square9);
//Add listener
Square1.addActionListener(this);
Square2.addActionListener(this);
Square3.addActionListener(this);
Square4.addActionListener(this);
Square5.addActionListener(this);
Square6.addActionListener(this);
Square7.addActionListener(this);
Square8.addActionListener(this);
Square9.addActionListener(this);
window.setVisible(true);
}
//ActionPerformed …
Hidden_mistakes 0 Light Poster
Ok thanks for that i changed it so it says
Square1.setIcon(mark);
Square1.setEnabled(false);
However now i have an error message- is there anything else i might need to change to get it to work?- it runs but when the button is pressed nothing happens
Hidden_mistakes 0 Light Poster
Hi ive been working for a few days now trying to figure out how to make it so when a button is pressed in this game instead of just a simple X or O showing up an image of lets say a dog for X and a cat for O or something along these lines would show up instead- i cannot figure it out so would any one be able to help me? Ive got it so the words scr/x(or)o.jpg show up but no image :(
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import java.awt.Color;
import javax.swing.ImageIcon;
public class TicTacToe extends JPanel implements ActionListener
{
//Class constants how big ect the window will be
private static final int WINDOW_WIDTH = 400;
private static final int WINDOW_HEIGHT = 400;
private static final int TEXT_WIDTH = 10;
ImageIcon X =new ImageIcon("scr/x.jpg");
ImageIcon O= new ImageIcon("scr/o.jpg");
/*Sets up the a 3 by 3 playing grid used the supplied java help
to figure this out*/
private static final GridLayout Layout_Style = new GridLayout(3,3);
//Button and window-how the frame and buttons or squares should look
private JFrame window = new JFrame("TicTacToe");
private JButton Square1 = new JButton("");
private JButton Square2 = new JButton("");
private JButton Square3 = new JButton("");
private JButton Square4 = new JButton("");
private JButton Square5 = new JButton("");
private JButton Square6 = new JButton("");
private JButton Square7 = new JButton("");
private JButton Square8 = new JButton("");
private JButton Square9 = new JButton("");
String mark = "scr/x.jpg";
boolean win = false; …
Hidden_mistakes 0 Light Poster
Hi ive been working for a few days now trying to figure out how to make it so when a button is pressed in this game instead of just a simple X or O shows up an image of lets say a dog for X and a cat for O or something along these lines- i cannot figure it out so would any one be able to help me?
Hidden_mistakes 0 Light Poster
Ive been told that this code:
button.setBackground(Color.YELLOW)
will change the colour of the button which i added to this part of the code
Square1.setBackground(Color.YELLOW);
Square2.setBackground(Color.YELLOW);
Square3.setBackground(Color.YELLOW);
win=true;
}
But nothing seems to have changed- is there anything else that i might need to add to make this work?
Hidden_mistakes 0 Light Poster
I didn't look through all of it very carefully, but perhaps you want to define "notblack" to be a color other than black?
Color notblack = new Color(0,0,0);
I really wish it was this simple but i changed it to a colour and it made no difference what-so-ever which is highly annoying. Any other suggestions would be highly appreciated
Hidden_mistakes 0 Light Poster
I've managed to get the window to appear in the center so no longer need help with this.. Still trying real hard to get the colour to work however
Hidden_mistakes 0 Light Poster
also the tie button won't work, when its a tie nothing happens- any ideas as to why?
Also if possible i need help to this question ASAP
Hidden_mistakes 0 Light Poster
Hi i am using netbeans to make a tictactoe game so far this is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TicTacToe implements ActionListener
{
//Class constants
private static final int WINDOW_WIDTH = 400;
private static final int WINDOW_HEIGHT = 400;
private static final int TEXT_WIDTH = 10;
//Design
private static final GridLayout Layout_Style = new GridLayout(3,3);
//Instance variables
private JFrame window = new JFrame("TicTacToe");
private JButton Square1 = new JButton("");
private JButton Square2 = new JButton("");
private JButton Square3 = new JButton("");
private JButton Square4 = new JButton("");
private JButton Square5 = new JButton("");
private JButton Square6 = new JButton("");
private JButton Square7 = new JButton("");
private JButton Square8 = new JButton("");
private JButton Square9 = new JButton("");
String mark = "X";
boolean win = false;
Color black = new Color(0,0,0);
Color notblack = new Color(0,0,0);
//Constructor
public TicTacToe()
{
window.setSize(WINDOW_WIDTH,WINDOW_HEIGHT);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// exits the application one the game has been won
//Add to window the internet helped me to see what this should look like
window.getContentPane().setLayout(Layout_Style);
window.getContentPane().add(Square1);
window.getContentPane().add(Square2);
window.getContentPane().add(Square3);
window.getContentPane().add(Square4);
window.getContentPane().add(Square5);
window.getContentPane().add(Square6);
window.getContentPane().add(Square7);
window.getContentPane().add(Square8);
window.getContentPane().add(Square9);
//Add listener
Square1.addActionListener(this);
Square2.addActionListener(this);
Square3.addActionListener(this);
Square4.addActionListener(this);
Square5.addActionListener(this);
Square6.addActionListener(this);
Square7.addActionListener(this);
Square8.addActionListener(this);
Square9.addActionListener(this);
window.setVisible(true);
}
//ActionPerformed
public void actionPerformed(ActionEvent e)
{
int count=1;
do
{
if (e.getSource()==Square1)
//If user marks Square 1 then it will set a mark or it will continue on searching until a Square is marked
{
Square1.setText(mark);
Square1.setEnabled(false);
}
else if (e.getSource()==Square2)
{
Square2.setText(mark);
Square2.setEnabled(false);
}
else if (e.getSource()==Square3)
{
Square3.setText(mark);
Square3.setEnabled(false);
}
else if (e.getSource()==Square4)
{
Square4.setText(mark); …