Checker Game Move And Jump Algorithm

Sep 7, 2014

I'm trying to make a checkers game in Java and I managed to make my grid with it's button on it. Each button which has a pawn on it has it's own actionListener which was all done in the loop as I made the grid as shown in my code below. Now I have a huge problem. I don't know how to handle the move, check if move is legal, jump and double jump. Here is the code I wrote so far. I wrote it in such a way that all the buttons which have a pawn on them can perform the same action but then I'm completely stuck.

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class CheckerBoard extends JPanel{
public static final int WIDTH = 530;
public static final int HEIGHT = 530;
private JButton[][] grids;

[Code] .....

View Replies


ADVERTISEMENT

Checker Game With Minimax Algorithm

Apr 12, 2015

I have a checker game already and I am trying to make an AI opponent even if not so Intelligent as long as it can move chips on its own until the game is over.

View Replies View Related

2D Slide Scrolling Game - Character Cannot Jump

Mar 31, 2014

There is a problem in my 2D slide scrolling game where the character can't jump until he reaches the enemy.

The Boards class-

package OurGame;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
public class Board extends JPanel implements ActionListener, Runnable {

[Code] .....

View Replies View Related

Game Run But Snake Does Not Move / Apples Are Spawned Everywhere

Apr 19, 2014

I tried to make a runnable snake game. When i try to run my code i get this:

Exception in thread "main" java.lang.NullPointerException
at Game.Move(Game.java:85)
at Game.run(Game.java:244)
at Game.main(Game.java:38)

The game runs, but the snake doesn't move, and apples are spawned everywhere.

Here are Move, run and main code:

public static void main(String[] args) {
JFrame frame = new JFrame("Snake");
Game game = new Game();
frame.add(game);
frame.setSize(406, 430);
frame.setVisible(true);
frame.setResizable(false);

[Code] .....

View Replies View Related

Tic Tac Toe Game - Minimax Algorithm

Jan 4, 2014

I have been trying to create an algorithm for the computer in my Tic-Tac-Toe game? So I searched for some good ones, and found about this confusing but effective algorithm, at least if you get it working, called Minimax. I tried implementing it into my game. Let's say it was easier said than done. Sometimes I think it's working, but sometimes it doesn't work at all. How do I get my algorithm working? What the variables BEST_SCORE_COMPUTER and BEST_SCORE_PLAYER in my code should have as starting values.

Java Code:

import java.util.Scanner;
public class TicTacToe{
private static char BOARD[] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}; // This is the main board itself.
private static int ROWS[][] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}}; // These are all the rows one can win by filling.
private static int SCORE, BEST_MOVE_COMPUTER, BEST_SCORE_COMPUTER = -1, BEST_SCORE_PLAYER = 1; // These variables speak for themselves.
private static byte TURN = 1; // 1 means player's turn, and 2 means computer's turn.

[Code] .....

View Replies View Related

Snake Game Movement Algorithm

Jun 16, 2014

I am working on replicating this project: [URL] ....

What is wrong with the moveSnake method and the for loop within it?

View Replies View Related

Android Racing Game - Algorithm Efficiency

Feb 6, 2014

I am making an android racing game. I have a method that draws the track to the screen, the map is bigger than the screen so i clip the bitmap and draw it to the screen hence to draw the track I have to get the visible track points and then draw them. I have noticed that when I enable drawing the track the game lags quite a bit but when i disable it is smooth as expected the code is below :

public void drawTrack(Canvas canvas) {
if (this.trackPoints != null && this.trackPoints.size() > 0) {
 // get points, convert back to screen coords and add them to array,
// then
// use that arraylist<point> below
getCurrentVisibleTrack();
counter++;
if (this.visibleTrackPoints.size() > 0) {
 
[Code] .....

View Replies View Related

JSP :: Send Variable In Anchor To Same Page Jump

Aug 2, 2014

// code for this file including sql query for 1st <c:forEach> tag which is working fine.
<table>
<c:forEach items="${rs.rows}" var="data">
<tr>
<a href="res_pkey=${data.discount_PKey}#my-offers" data-toggle="modal">
<s:query var="rs2" sql="select * from discount where discount_id='${data.discount_PKey}' " ></s:query>
<c:forEach items="${rs2.rows}" var="data2">

[code]....

code is working fine, please check the red coloured lines in code above, here i want to send different value of res_pkey to my-offers according to the user selected row of the table, thats why i am using it in the anchor tag.previously i tried : <c:set> but it updates its value during loading of the page and set it to the last row's value.I want : when user select a row, only that perticular value should be given to tha my-offers

View Replies View Related

Scrolling Panel - Making A Sprite Jump

Apr 6, 2014

I am currently making a platformer game which involves a scrolling panel and a sprite. My intention is for the sprite to be able to jump. My code for the frame that the scrolling panel sits on looks like this:

package Main;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
 
[Code] ....

Currently I have the sprite (jumpMan) displayed on the JumpPanel. This is where I have a key listener that intends to control the jumping of the sprite by incrementally moving the sprite through the space to simulate jumping slightly more accurately. The JumpPanel is laid on top of a panel called the GamePanel which sits between the main frame and the JumpPanel. I currently have a timer on the main frame which is firing off the action listener every 5ms.

My hope was that the action performed would repaint at intervals so that the you would be able to see the sprite at different stages of the jump and then as it descends as well. However when I try to make the sprite jump nothing happens, nothing changes on the screen - when I debug through I can see the code going into both the keyPressed and actionPerformed methods but this doesn't seem to do anything.

View Replies View Related

Jump Games - Put Images Into JTable For Organization And Character Selection Purposes

Jul 14, 2014

HTML Code:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.imageio.ImageIO;
public class Main extends JApplet implements Runnable, ActionListener {

[Code] .....

I am making a game and there are two problems that I have and can't seem to solve. I never made on applet before, and I'm not good with the swing components, but I am decent programming in Java.

Problem #1: the start button is in the JPanel, I don't want that, I want it to be above the JPanel.
Problem #2: I want to put images in to a JTable for organization and character selection purposes, but I keep on getting a string. Do I have to use an ImageIcon to get it to work, or does it matter?

In case you were wonder what kind of game I'm making, I'm making one of those jump games where you jump on platforms and try to go as high as you can without missing a platform. There is going to be character selection for the jumper, and the jumpers are going to be food, like a potato, a banana, a strawberry, etc.

View Replies View Related

Password Strength Checker

Mar 4, 2014

It had no syntax error but if there would be any other error or if i would receive a wrong result

import java.util.*;
class tester {
public static void test() {
Scanner input=new Scanner(System.in);
int size= 0;
System.out.println("Enter your password:");
String enter=input.next();
size = enter.length();

[Code] .....

View Replies View Related

Simple Password Checker Into JOptionPane?

Sep 1, 2014

i have this source code...

import java.util.Scanner;
//I had to use scanner in this program because I had to create objects that were in the Scanner class, such as in row 16.
* This program confirms a password typed into a *
* console window *
*/
 public class Homework1 {
public static void main(String[] args) {
//Needs to add a scanner to the program to continue on
Scanner keyboard = new Scanner(System.in);

[code]....

Now I need to create a second version of this program that uses JOptionPane to get the inputs from the user and show the output!

View Replies View Related

Programming A Simple Password Checker

Aug 30, 2014

Use Java to write and run a simple console-window program for checking passwords. The program must satisfy the following requirements:

-When the program runs, it should first print its name, e.g., Password Checker
-The program should next prompt the user to enter a username, e.g.,

Please enter your username:

-The program should next prompt the user to enter a password, e.g., Please enter your password:
- If the user enters a correct password, i.e., one that matches an internal secret password, the program responds. You are approved by access control!, and quits.
-If the user enters an incorrect password, the program responds

Try again:
-If the user enters a correct password matching the secret one, the program responds. You are approved by access control!, and quits.
-If the user enters an incorrect password, the program responds

package class1;
import java.util.Scanner;
public class class1 {
public static void main(String[] args) {
// TODO Auto-generated method stub

[code]....

View Replies View Related

Int Cannot Be Converted To Boolean On Password Checker Program

Apr 28, 2014

I am trying to write a password checker program and thats the error i get. (the final error!) but this one i dont know how to fix. here is my code.

/* Text
Text
text
*/

import java.util.Scanner; // Imports the Scanner class to get Keyboard Inputs
class PriceRichardChapter5Test
{
public static void main (String [] args) {
String Password; // Creates the Password variable

[Code] .....

View Replies View Related

Spell Checker Using Hash Tables Not Working

Feb 10, 2014

I am trying to use this program for reference but its not working ...

View Replies View Related

Sudoku Checker Program - Cannot Find Symbol

Jul 9, 2014

I can't get the code to compile for the driver every time i get an error message saying

SudokuCheckerTest.java:28: error: cannot find symbol
foo.displayGrid(grid);
^
symbol: variable grid
location: class SudokuCheckerTest
SudokuCheckerTest.java:29: error: cannot find symbol
foo.getGrid(grid);

[Code] .....

4 errors

Java Code :

import java.util.Scanner;
public class SudokuChecker{
public SudokuChecker(){
// displays intro code and initializes the array grid as well as using method calls.
Scanner in = new Scanner(System.in);
int [][] grid = new int [4][4];
displayGrid(grid);

[Code] ....

View Replies View Related

ArrayList Features - Implement Password Strength Checker

Jun 18, 2014

Iv created an array list which contains people and attributes such as user id, username etc. It works fine for the most part. It allows the user to enter a name into the system. If the name entered matches a name stored in the array list then it will display that user, its id, name and password. I need to implement a password strength checker; but i am struggling.

First off; i need a method that will determine how strong a password is. I then need to find a means of how to output the result of this, outputting it alongside the other outputted attributes: id, name and password.

Here is what i have attempted so far, but to be honest its probably completely different to the exact strength check and way that i want the result to be displayed. I know that the code below is a good start, but its not close to implementing the code in a way that the password strength result can be outputted in the arraylist after a search for a user and their password is made.

private int checkPasswordStrength2(String passw)
{
int strengthCount=0;
String[] partialRegexChecks = { ".*[a-z]+.*", // lower
".*[A-Z]+.*", // upper
".*[d]+.*", // digits
".*[@#$%]+.*" // symbols
};
if (passw.matches(partialRegexChecks[0])) {

[Code] .....

I just really want to get this done. Iv looked for solutions online; but they implement a password strength checker much differently to how mine needs to work from what i can tell.

View Replies View Related

JSF :: Move Datatable Rows Up And Down?

May 22, 2014

I have a requirement like in a Rich datatable, and i have placed two links up and down in one of the column of each row, here i wanted to swap rows (move up/ down ) the rows when i click the link on a perticular row. is it possible with jsf/ java script?

View Replies View Related

How To Move JLabel In JPanel

Jan 9, 2014

I am trying to move a JLabel in a JPanel, but can't seem to make it work. I can't provide a compiling code, but a few fragments. I have a JLabel [] array. i want to move with the mouse elements of this array. Let's say i want to move JLabel[i]. I implemented this:

Java Code:

static int labelY;
static Point labelX;
static Boolean flag = false;
jLabel[i].addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent evt){
labelY=evt.getY();

[Code]...

I used the bool flag because i can't make changes to the label when it is inside an anonymous class. I also tried using setLocation but that did not work also. I don't get any errors when compiling. But when i run it and try to drag the JLabel[i] i get a long list of errors:

Java Code:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at puzzle.hw$1$2.mouseDragged(hw.java:276)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)

[Code]...

View Replies View Related

Trying To Make The Image Move

Oct 27, 2014

I am having trouble making my image move to a certain position in a certain amount of time which is set inside a text file. I was wondering what I'm doing wrong and what I'm missing.

import java.io.*;
import java.util.*;
import java.io.FileReader;
public class Animator {
EZImage HP;

[code]....

View Replies View Related

How To Keep Character In Place With Up And Down To Move

Jan 30, 2014

I noticed it is a huge success to have the backgrounds of games move and the character just move up and down and dodge obstacles.How Do I make a background that scrolls horizontally to the left? I know how to keep the character in place with up and down to move, but not sure how to go about making the background move with obstacles.

View Replies View Related

Character Won't Move When Key Is Held

May 29, 2014

I was just trying to figure out why when I hold down a movement key, that my character doesn't move. It only moves if I continuously press the movement key. Here is my code:

package game;
import java.awt.*;
import TileMap.TileMap;
import Handlers.Keys;
public class Player {
private double x;
private double y;

[Code] .....

View Replies View Related

How To Move Multiple Objects At Once

Oct 8, 2014

I am new to Java programming and i am using BLUEJ to create some basic objects etc.

I have 3 circle objects (individual) and i am wanting to use "slowMoveHorizontal" method to move these 3 objects about 50px to the right.

So far, everything works BUT the issue is that they do NOT move together simultaneously. They move on a ONE BY ONE basis.

View Replies View Related

Servlets :: How To Move To Another JSP Page

Mar 27, 2014

I have created a authentication servlet as follows :

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub
/* Connexion la base de donnees */
try {
Class.forName("org.postgresql.Driver");
System.out.println("Driver O.K.");

[code]...

I just want to know how can i move to another jsp page from my servlet.

View Replies View Related

Move A Methods To A New Class

Feb 5, 2015

there are two classes here. I need to put the max and min methods should be in the tester class, but I have tried moving it to the tester class and it will not comply. When I run I get a list of errors of "Error:(43, 9) java: illegal start of expression

Error:(43, 16) java: illegal start of expression
Error:(43, 22) java: ';' expected
Error:(43, 41) java: '.class' expected
Error:(43, 52) java: illegal start of expression
Error:(43, 51) java: not a statement
Error:(43, 53) java: ';' expected
Error:(57, 9) java: illegal start of expression
Error:(57, 16) java: illegal start of expression
Error:(57, 22) java: ';' expected
Error:(57, 41) java: '.class' expected
Error:(57, 52) java: illegal start of expression
Error:(57, 51) java: not a statement
Error:(57, 53) java: ';' expected"

package A808;
public class FuleTesterV1
{
public static void main(String[] args)
{
String titleLines;
titleLines = "Yearly Gas Mi Calc | Assignment 8.08";
String TitleLines;
TitleLines = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

[code]....

View Replies View Related

How To Move Along A Doubly Linked List

Dec 11, 2014

I'm having some trouble with figuring out how to move along a doubly linked list for an assignment. The program is supposed to be a simple board game simulation. Here is what I have so far:

Space.java:

public class Space
{
private String name;
public Space next;
public Space previous;
public Space(String name)
{
this.name = name;

[Code]...

I seem to have been able to get all the other methods working properly, but I am pretty stuck on how to do the movePlayer. Specifically because it is passing an integer, but my objects are of type Space and Boardgame.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved