// Import section
// Use this section to add additional libaries for use in your program.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Math;
// This begins the class definition.
// Notice that this is a "world". You can tell since it extends Applet.
public class BlackJack extends Applet implements Runnable, /*KeyListener,*/ MouseMotionListener, MouseListener
{
//variable declaration section
// public datatype variablename
public int xTitle;
public int yTitle;
public Card[] Cards;
public int sizeC;
public int randomXpos, randomYpos, randomCard;
public Image cardDeck;
Graphics bufferGraphics;
Image offscreen;
//Sets up a Thread called thread
Thread thread;
// Method definition section
// init() is the first method an Applet runs when started
public void init()
{
//Initialize variables
xTitle=250;
yTitle=50;
sizeC = 52;
Cards = new Card[sizeC];
/*for(int j = 0; j<13; j++)
{
for(int i = j; i<52; i = i+13)
{
Cards[i].value = j+1;
Cards[i].number = j+1;
}
}*/
for(int i = 0; i < 13; i++)
{
Cards[i].suit = "Spade";
}
for(int i = 13; i < 26; i++)
{
Cards[i].suit = "Club";
}
for(int i = 26; i < 39; i++)
{
Cards[i].suit = "Diamond";
}
for(int i = 39; i < 52; i++)
{
Cards[i].suit = "Heart";
}
cardDeck = getImage(getDocumentBase(), "CardDeck.gif");
//double buffering
offscreen = createImage(800,600); //create a new image that's the size of the applet
bufferGraphics = offscreen.getGraphics(); //set bufferGraphics to the graphics of the offscreen image.
setSize(800, 600);
addMouseListener(this);
addMouseMotionListener(this);
//Set up the thread
thread = new Thread(this); //constructs a new thread
thread.start(); //starts the thread
}//init()