Gridworld Chess Pawn Not Working
May 26, 2014
I am making a chess game in Gridworld. My pawn method is not working. For example, when I use getMoveLocations() on a pawn the first time, it brings up both valid moves. Once I move it two spaces and use getMoveLocations() again, it brings up the space behind the pawn. When I move it there, and then I use getMoveLocations(), it just brings up an empty ArrayList.
Pawn class
import info.gridworld.actor.Actor;
import info.gridworld.grid.*;
import java.util.ArrayList;
import java.awt.Color;
[Code] .....
View Replies
ADVERTISEMENT
Mar 14, 2014
I've been using grid world with my school. It's a part of the eimacs textbook. the following code that I wrote for gridworld. It's a very small tad bit of code:
Actor actor = new Actor();
actor.putSelfInGrid( grid, new Location( 5, 3 ) );
public void setColor (Color RED);
I get the following error:
error: illegal start of expression
public void setColor (Color RED);
View Replies
View Related
Apr 9, 2014
gridworld snake game all over the internet, but all of those are the "snakebug extends Bug" version, mine is different. im behind everyone else in apcs so i rarely have any idea what im doing(gridworld especially). our teacher gave us most of the code, which i coped down (hopefully correctly) and he told us that we still needed to fill in the "removeTail" method which i did. basically the snake moves by placing a segment in front then removing the last segment.
When i click run the snakerunner file, i can make the snake segment rotate by pressing the arrow keys, but it doesn't move. when i click the "run" on the gridworld window, the single snake segment just disappears. so the move method is triggering the "removetail" method but it isn't placing the next segment. im starting to think that i copied something wrong from the board, because he showed us the entire move method. i have attached my gridworld files, what is wrong with my snake.java that makes the move method delete a segment but not add one
View Replies
View Related
Jun 5, 2014
I have a question about updating a grid during runtime in GridWorld. I'm making a game called Flood-It (basically, you click on squares to change their color and attempt to get all of the squares the same color in the grid) and I'm having trouble with changing the grid size. I made my own world class, called CellWorld.
import info.gridworld.actor.*;
import java.util.ArrayList;
import info.gridworld.grid.Location;
import java.awt.Color;
import javax.swing.JOptionPane;
[code]...
Now, let me narrow down the issue. It is in the runner class:
world.setGrid(new BoundedGrid<Actor>(world.getLength(),world.getWidth()));
Whenever a user wants to change the grid size after playing the game, this is supposed to set the grid to the new updated size, but it never changes in the actual game, i.e. the user just won a 2x2 game, attempts to change the size to 10x10, but the grid stays 2x2. By debug testing, I can say for certain that everything else works, such as the maxStepCalc and loading the grid. The only issue is the new grid not showing up.
View Replies
View Related
Dec 7, 2014
I'm having difficulty adding Chess Pieces to my Java Program. The Problem being that I'm unable to figure out how to add a chess piece to their corresponding location on a chess board. I've tried several things but nothing seems to work. This is what I have so far.
public class ChessGUI extends JPanel {
public int squareSize = 64;
public int x = 0;
public int y = 0;
private final JPanel GUI = new JPanel();
private JButton[][] chessBoardTiles = new JButton[8][8];
[Code] ....
So far I've just been testing stuff...
View Replies
View Related
Nov 17, 2014
Having some trouble coding this exercise in JAVA:
Build a backtracking algorithm to place n queens on a chess board of nxn, with no threat to any queen.
Using F=parameter, Print only the first result.
Using the same C=parameter, print every possible inlays.
This should work when running with a 4x4 board and an 8x8 board basically.
View Replies
View Related
May 10, 2014
So I'm making a trading card game and each card can be moved around like chess pieces. So far, I've made the cards simple rectangles and detect if clicks are made within that rectangle and then move them appropriately, but I'm not sure if that's the best solution.
View Replies
View Related
Apr 10, 2014
I am developing an application to share my client screen with server, it is working well on swing. But i want to develop as web application, i am trying to using applet. But i am facing the fallowing problem..,
1) The Applet screen also open and project also running well on server mechine. But unable to see the client screen on the server.
2) The problem may be to display the JDesktopPane or JInternalFrame.
My working Server Code extends withe JFrame..Java Code:
package remoteserver;
import java.awt.BorderLayout;
import java.awt.Container;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JApplet;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
[code]....
View Replies
View Related
Aug 29, 2014
Why in my program keys are not working, what I forgot to write?
import javax.swing.JFrame;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Stickman");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(450, 490);
[code]....
View Replies
View Related
Mar 5, 2014
I got my code into a jar, but when I run it I get his message:I just used Eclipse to make my jar and I thought I did it right but I guess not.
View Replies
View Related
Apr 24, 2014
I wrote a piece of code:
for(int i = 0; i < x; i++){
System.out.println("Enter students full name:");
sName[i] = result.fullName(sc.nextLine());
sExam[i] = result.examName("VB");
System.out.println("Enter students exam score:");
int scor = sc.nextInt();
sScore[i] = result.examScore(scor);
sGrade[i] = result.examGrade(scor);
}
When i run it i get:
Enter number of students:
1
Enter students full name:
Enter students exam score:
The problem is, i cant enter "full name", program is just jumping to the next step "exam score".
View Replies
View Related
Oct 9, 2014
I am working on a fairly simple program where I have a colour change three times using the red green blue spectrum. The problem is that I keep getting a result of zero no matter what I do.
import java.awt.*;
class RectangleMain
{
public static void main (String[] args) {
ColouredRectangle blocky = new ColouredRectangle(50, 100, 20, 40, Color.red);
System.out.println(blocky.getColour());
blocky.mixColour(Color.blue);
[code]...
View Replies
View Related
May 31, 2014
I'm programming a game, but the keyListener doesn't work. Here is the source code:
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class InputHandler implements KeyListener{
public InputHandler(Game game) {
game.addKeyListener(this);
[code]....
My Question is: Why will it not say "up", if I press "w"?
View Replies
View Related
May 5, 2014
I'm having a problem where an if statement isn't working. In the Person class boolean olderThan ignores my if statement so it always returns false and I just don't get why that's happening.
import java.util.Calendar;
public class Person {
private String name;
private MyDate birthday;
public Person(String name, int pp, int kk, int vv) {
this.name = name;
[code].....
View Replies
View Related
Feb 25, 2015
I have added a Simple Jar file in Eclipse Proect->BuildPath->jar file but class Inside that are not showing in My project this is my Project Structure and I have all ready checked in Order and Export..But jar file is not working.
View Replies
View Related
Sep 7, 2014
I am learning out design patterns and doing a little fun project on Model Control View (MCV). I got the concept down, it is pretty simple for the most part. However my buttons are not working.
Here is the code:
public class Controller
{
private Model model;
private View view;
Controller(Model model, View view) {
this.model = model;
this.view = view;
[code]....
It runs but nothing. My other questions is how can I make a box that will print the results.
View Replies
View Related
Apr 4, 2014
I need to find out if one array list is a sub-sequence of another. The elements in the first list all need to be in the second list and must be in the same order. So s1<n, t, a> is a sub-sequence of s2<q, n, f, r, t, d, a>, but s1<a, a, t> is not a sub-sequence of s2<a, t, a>. I need to use iterators to go through each list, and I should only go through each list once (since it has to be in the same order) so nested loops don't seem like they would work because it would start at the beginning of one list every time it moved to another element in the outer loop's list.I seem to have an issue where the itr1. next()
is ignored when in an if statement.
My current code just stalls and will never stop running. I've also switched things around and put the not equal check after the if it is equal and it throws a NoSuchElementException.
import dataStructures.*;
public class Subsequence3
{
public static void main(String[] args)
{
ArrayList<Character> s1 = new ArrayList<Character>();
s1.add('n');
s1.add('p');
s1.add('a');
[code]....
View Replies
View Related
Feb 2, 2014
the problem which im facing when executing jar file is it is not working same as when i run file using the IDE.When run jar file, it won't open the new frame even the user and pass combination correct.But when i'm compiling using the IDE, it works as charm. The main menu popped up after i logged in.I've tried Clean and Build and it's not working too.
View Replies
View Related
Oct 14, 2014
I code a program using Eclipse Keppler with Java 8.0. I made a program with 2 JPanel. The first JPanel is working well. From a button in first JPanel, I excute second JPanel, but It is not working. No error when I compile the code. Here is, I attached the source code.
import javax.swing.*;
import java.awt.Color;
import java.awt.event.*;
[code]....
View Replies
View Related
Oct 29, 2014
working on a project but cant seem to get my while loop to restart i want to restart this guessing game if the user inputs y at the end otherwise it will end.
import java.util.Scanner;
import java.util.Random;
public class GuessingGame{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String again = "y";
while(again=="y"){
[code]....
View Replies
View Related
May 5, 2015
i am trying to make taxi meter which shows the current price.Rightnow I have to click startmeter afterevery 1 minute than it's update the new price but I want it to update automatically once the price change after 1 minute instead of me pressing startmeter everytime.This is my 1st time I am using timer class. I am not sure why timer is not working.
import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.awt.event.*;
[code]....
View Replies
View Related
Jul 18, 2014
i have a problem with the jsf 2.0 version with inplace select,in jsf 1.2 it was working, but in jsf 2.0 it is not
problem: when select one of the item in inplace select dropdown,I am trying to update it with the selected value using the a4j:ajax tag, using but the control is not calling the update() method
<rich:column id = "locationClmn">
<f:facet name = "header">
<h:outputText id = "LocationHeder" styleClass = "headerText"
value = "#{messagesRefdata['notifications.locations']}"/>
</f:facet>
<c:set var = "locations" value = "#{notificationConfigurationBean.listOfLocations(ntc.notification)}"/>
<rich:inplaceSelect value = "#{ntc.location}" showControls = "true"
[code]....
I have even tried f:ajax, execute= "@this", immediate = true.
View Replies
View Related
Apr 13, 2014
there is no divider in the operation. Iadded a print i to confirm the loop works. I tried with and without the brackets..Can you use the i in the operations of the loop? I figured I could since printing it out give me a list of numbers
public class harmonique {
public static void afficherHarmonique( int wholeNumber ) {
int harmonique = 1;
for( int i = 2; i <= wholeNumber + 1; i = i + 1 ) {
System.out.println ("i =" + i);
harmonique = harmonique + (1/i);
System.out.println ("harmonique =" + harmonique);
}
}
}
View Replies
View Related
Jun 2, 2014
Currently the while near the end is not working in netbeans. It is saying illegal start of type. This whole section was working before when it was within the public static void method. I moved it to a separate class to try and clear up a, static variable problem. My question is can i fix it to keep it structured this way. Or do I have to put it back into the main method and try to work out the static variable problem a different way.
public class InventoryProgram {
double[] dvdprice; // defines variables
int[] dvdnum;
int[] dvdstock;
String[] dvdnames;
int count;
double total;
[code]....
View Replies
View Related
Feb 26, 2015
The class gets complied but when I run the program the submit button doesn't work, how do i get that to work?
/**
* Orchestration class for Account
*/
import java.awt.*; //Importing the java.awt.* class
[Code].....
View Replies
View Related
Feb 14, 2014
I'm trying to get a progress bar to work on my GUI.
This is what I have so far, the parameters are taken from another class that takes in an image in packets from a Raspberry Pi and stores them to a file on PC.
public void ImageInfoReceivedHandler(int sizeOfFile) {
progressBar.setMinimum(0);
progressBar.setMaximum(sizeOfFile);
progressBar.setIndeterminate(false);
[Code] .....
The println are printing out the correct values and they are being implemented in the methods, but nothing is happening in the GUI.
I have a thread setup in the GUI when a button is pressed
getImageButton.setText("Timer Started");
transmit = new transferImage(port);
lblImgProcess.setText("Getting Image, Please Wait");
transferThread = new Thread(transmit);
transferThread.start();
So the thread starts and image is then transmitted, does the progress bar need to be in that event handler?
View Replies
View Related