Rush Hour Game

Jun 2, 2014

I am creating the rush hour game. I am using the cars and trucks as Jlabel. I have created a 6x6 grid using GridLayout and I need to place the cars or trucks into the grid. I know how to place into a grid a Jlabel that takes only one cell. But how do you place a Jlabel that takes up more than one cell? For example, the cars occupy two cells on the grid, and the trucks 3 cells

View Replies


ADVERTISEMENT

Rush Hour Puzzle - Adding Multiple Vehicles

Jun 8, 2014

When I add the first car only, it puts it in the correct spot and I can move it correctly. However when I attempt to add another car, the image of the second car repaint itself onto the first one, and the second car is not functioning at all (not moving)...

[code=Java]

View Replies View Related

Changing Hour To Minutes?

May 1, 2014

I have a servlet with a method:

/**

* @return <code>double</code> Hours
*/
public double getDriveHours() {
return getAsDouble("DriveTime", 0.0D);
}

I would like to change the time to minutes. I will create a new entry in the db for the minutes, but wondered if the time minutes is also double.

View Replies View Related

I/O / Streams :: How To Grab Last One Hour Data From Log File

Jul 17, 2014

I have a log file which goes like this..

INFO: Jul 07 00:00:15 DataSource 2zvw8p93107gev14wko86|34e51ca2: Total connections 4 idle 4 busy 0 unclosed orphans 0 pool unknown
PERFORMANCE: Jul 07 00:00:15 Garbage Collection: ParNew 5 51ms in 59 seconds. [SpeedoLoggingBean] Thread SpeedoBean
INFO: Jul 07 00:00:15 Speedo: 2,222,786K of 4,054,528K - 1,831,741K free, 4,952epm, 1 buffered, 216 threads, 49.1% CPU, permgen 173,731K of 262,144K - 88,412K free
Jul 7, 2014 12:00:15 AM org.geotools.data.wfs.v1_0_0.WFSTransactionState commit
SEVERE: number of fids inserted do not match number of fids returned by Transaction Response. Got:1 expected: 0

[code].....

What I need is to grab only the last hour data from this log file?

View Replies View Related

Opoly Game - Goal Of The Game Is To Reach Or Exceed Reward Value 1000

Mar 12, 2015

Opoly works this way: The board is a circular track of variable length (the user determines the length when the game app runs). There is only one player, who begins the game at position 0.

Thus, if the board length is 20, then the board locations start at position 0 and end at position 19. The player starts with a reward of 100, and the goal of the game is to reach or exceed reward value 1000. When this reward value is reached or exceeded, the game is over. When the game ends, your program should report the number of turns the player has taken, and the final reward amount attained.

In Opoly the game piece advances via a spinner - a device that takes on one of the values 1, 2, 3, 4, 5 at random, with each of the five spin values equally likely.

Although the board is circular, you should draw the state of the board as a single "line", using an 'o' to represent the current player position, and * represent all other positions. Thus if the board size is 10, then this board drawing:

**o******

means that the player is at location 2 on the board.

Here are the other Opoly game rules:

If your board piece lands on a board cell that is evenly divisible by 7, your reward doubles.

If you land on the final board cell, you must go back 3 spaces. Thus if the board size is 20, the last position is position 19, and if you land there, you should go back to position 16. (If the position of the last cell is evenly divisible by 7, no extra points are added, but if the new piece location, 3 places back, IS evenly divisible by 7, then extra points ARE added).

If you make it all the way around the board, you get 100 points. Note that if you land exactly on location 0, you first receive 100 extra points (for making it all the around), and then your score is doubled, since 0 is evenly divisible by 7,

Every tenth move (that is, every tenth spin of the spinner, move numbers 10,20,30,... etc.), reduces the reward by 50 points. This penalty is applied up front, as soon as the 10th or 20th or 30th move is made, even if other actions at that instant also apply. Notice that with this rule it's possible for the reward amount to become negative.

Here is the driver class for the game:

import java.util.*;
public class OpolyDriver{
public static void main(String[] args){
System.out.println("Enter an int > 3 - the size of the board");
Scanner s = new Scanner(System.in);
int boardSize = s.nextInt();

[Code] ....

heres the methods:

REQUIRED CODE STRUCTURE: Your Opoly class must include the following methods (in addition to the Opoly constructor) and must implement the method calls as specified:

playGame - The top-level method that controls the game. No return value, no parameters. Must call drawBoard, displayReport, spinAndMove, isGameOver.

spinAndMove - spins the spinner and then advances the piece according to the rules of the game. No return value, no parameters. Must call spin and move.

spin - generates an integer value from 1 to 5 at random- all equally likely. Returns an integer, no parameters.

move - advances the piece according to the rules of the game. No return value, takes an integer parameter that is a value from 1 to 5.

isGameOver - checks if game termination condition has been met. Returns true if game is over, false otherwise. No parameters.

drawBoard - draws the board using *'s and an o to mark the current board position. Following each board display you should also report the current reward. No return value, no parameters.

displayReport - reports the end of the game, and gives the number of rounds of play, and the final reward. No return value, no parameters.

View Replies View Related

Tic Tac Toe Game - Random Number Generator And Two Dimensional Arrays For Game Board

May 9, 2015

Im trying to make a tic tac toe game that you play against the computer using a random number generator and two dimensional arrays for the game board. Im not trying to make a GUI, the assignment is to have the board in the console, which I have done. I have run into a few problems with trying to get the computer player to correctly generate 2 integers and have those two integers be a place on the game board. Here is my code so far.

import java.util.Random;
import java.util.Scanner;
 public class TicTacToe {
 private static Scanner keyboard = new Scanner(System.in);
private static char[][] board = new char[3][3];
public static int row, col;
 
[Code] ....

View Replies View Related

Guessing Game - How To Reset Random Number When User Reset Game

Oct 2, 2014

I tried this program, its guessing game. Where program decide 1 number and user will guess number. I am getting 1 problem. When user want to play game again.the random number remain same. So where i can put reset random in code..? And 1 more question if I want to write driver code for this. What should i transfer to driver code.

import java.util.Random;
import java.util.Scanner;
public class GuessGame {
public static void main(String args[])
{
String choice="y";

[Code] ......

View Replies View Related

Moving A Map In A Game

Jul 22, 2014

I've been at this for a while and I would like to make the Camera in my game follow the player and I know the way to do this would be to move the map and not the player. How would I do this if my map is rendered from a text file using for loops. Here is my code for the map.

package Game;
import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Map {

[Code] .....

View Replies View Related

Getting TIE In Connect 4 Game?

Oct 20, 2014

I have compiled and coded the whole thing, but the TIE function when no one wins, isn't popping up. I'm not sure why but here is my code;

import java.applet.AudioClip;
import java.awt.*;
import javax.imageio.ImageIO;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;

[code]....

The TIE doesn't pop up, that is all the errors i have, though there is no error messages.

View Replies View Related

How To Add A Scorekeeper For Game

Apr 3, 2014

I am creating a simple AirHockey game in Eclipse Java Jframe. I was just wondering how it is i add a score keeper to my game. for example if player 1 scores a goal 1 is added onto there score at the top.

View Replies View Related

Tic Tac Toe Game Using While Statements

Oct 23, 2014

import java.util.Scanner;
public class TicTacToe {
public static void main(String[] args) {
//Create scanner
Scanner in = new Scanner(System.in);
//Declare variables to hold the board

[Code] ....

I need to create a while statement for random computer moves.

View Replies View Related

Tic Tac Toe Game Based On GUI

Apr 26, 2014

My instructor told me to make game from java but based on GUI. And I thought about it, I want to make Tic Tac Toe (X-O) game.

View Replies View Related

KeyBindings For A Game

Jan 26, 2014

I'm making a game which lets the player move around with arrow keys, but my KeyListeners are working less-than-satisfactorily. I googled this and I found that I should use KeyBindings.

1) Right now I have booleans for each key used in the game. When a key is pressed, the boolean is set to true, and set to false when it is released. In the ActionListener for the Timer I have, I then check if each is pressed or not, and do the corresponding action. I do this so that movement is smooth.If I was to use KeyBindings, would I use the same technique, or would I just do the action in their Action?

2) How do I do it? From the example I thought was most useful, this is my guess: (this code would be in a JPanel)

Java Code:

this.getInputMap().put( KeyStroke.getKeyStroke( "ENTER" ) , "doEnterAction" );
this.getActionMap().put( "doEnterAction" , EnterAction );
static class EnterAction extends AbstractAction
{
public void actionPerformed( ActionEvent tf )
{
enterKeyIsPressed=true; //If using this method, I would also have a separate InputMapping, ActionMapping,

[code]....

View Replies View Related

Tic Tac Toe Game 2D Array

Apr 13, 2014

I know a lot of people taking beginning java courses have posted questions about creating a tic tac toe game, but here is another one. Below is my code. I can't seem to get the X's and O's to show up on the board or to determine a winner.

import java.util.*;
public class Trial3
{
public static char turn;
public static int count;
public static void main(String[]args)
{
Scanner input=new Scanner(System.in);
char[][]b=new char[3][3];
boolean flag=false;
count=0;

[code]....

View Replies View Related

Race Car Game

Oct 20, 2014

Create another class called Race with a main method. Make some Car objects, and use them in a race.The first race will have 2 cars. The main method only needs 2 local variables, i.e. the 2 Car objects.

-The length of the race is 1000.

-Both cars will start out with a speed of 30.

The race will be implemented as a loop. Each time through the loop:

-Your cars will move to a next location by adding their current speed to their location. (If the speed is 50, and they are at location 200, then change the location to 250.)

-Call out the race (SOPLs) like a NASCAR announcer: Andretti is in the lead at position 365. He is flying at 30 mph!

-Or It's neck and neck with both cars at position 45 or something more creative that you can come up with.

-Each car will increase or decrease their speed randomly each time through the main loop.

-The car that is behind will increase its speed by 2 mph, and the car that is in the lead will decrease its speed by 2 mph. (Tighten the race to make it more exciting.)

-The loop will continue until one of the cars is declared to be the winner.

This is my code so far.

public class RaceCarsMain {
public static void main(String[] args) {

int length = 0;

Cars c = new Cars("Andretti", 30);
Cars c2 = new Cars("Fiviotini", 30);
while (c.getLocation() < 1000){
length++;
c.randomSpeedChange();
c.accelerate(2);
c.deaccelerate(2);
c.locationchange();

[code]....

I have been able to print out the first car "Andretti" until its location reaches 1000, but the 2nd car I have not being able to print out the change of speed and change of location.how to proceed and making the 2nd car do the same, do I have to create another class? or how can i use the Cars class to do it for both.

View Replies View Related

2D Game Tile

Dec 16, 2014

When the tile loads it loads at the side where i wanted it to be and when my character falls down the image/tile stretches to the collision and stops. looks like this stretches.jpg

The character codes:
error.jpg

And for the Level:
error2.jpg

View Replies View Related

Connect Four Game

Nov 25, 2014

Our assignment is to make a version of the classic 'Connect Four' game, where we need to construct a GUI that shows the current state of the game and instead of having a winner once a player has four chips in a row, the game needs to continue until no chips can be placed anymore.We currently get stuck in the GUI part. Running it right now results in a board with empty spaces only. Also after choosing a column to place, the board remains empty.

Our question: How do we get the board filled with the right color of chips at the right place?We know the 'ArcsPanel'-class (almost at the bottom of the code) is wrong, but we don't know what to do to make it right.

Main class 'ConnectPanel':

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;

[code]....

At the moment, only the colors white, red and blue are used. This is purely for finding out how to work in general.

View Replies View Related

How To Get Sound To Import It To Game

Apr 7, 2015

how to make a simple game. I am having trouble when it comes to adding sound though. It tells me to do this:

package net.game.Game;
 
import java.applet.Applet;
import java.applet.AudioClip;
 public class Sound {
public static final AudioClip BALL = Applet.newAudioClip(Sound.class.getResource("ball.wav"));
public static final AudioClip GAMEOVER = Applet.newAudioClip(Sound.class.getResource("gameover.wav"));
public static final AudioClip BACK = Applet.newAudioClip(Sound.class.getResource("back.wav"));
}

What this does is it gets the sound file then gives it a name(BALL=ball.wav GAMEOVER=gameover.wav ect..) and then there is other code in other classes that call the sound so it will run but it keeps giving me an error and I don't know what to do. How can I get it to import the sound? Here is the error.

PHP Code:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at net.game.Game.stuff.<init>(stuff.java:35)
    at net.game.Game.stuff.main(stuff.java:62)
Caused by: java.lang.NullPointerException
    at sun.applet.AppletAudioClip.<init>(Unknown Source)
    at java.applet.Applet.newAudioClip(Unknown Source)
    at net.game.Game.Sound.<clinit>(Sound.java:7)
    ... 2 more 

View Replies View Related

Developing UNO Game In Java

May 11, 2014

I am new to java, i can develop basic java programs but am not really good at it. How should i pursue and how should i start. I know the game rules.Do i need to learn swings for the same?

View Replies View Related

How To Shuffle Numbers Every New Game

Dec 15, 2014

How to shuffle the numbers every new game? Heres my the code.

package project;
import java.io.*;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
public class khoProject {

[Code] ....

View Replies View Related

Tic Tac Toe Game - GUI Freezes When Someone Wins

Jan 16, 2015

This code is for a tic tac toe game. I have a action listener set up and if the user entered a move that would win the game of tic tac toe it would call on a restart() method to clear the board, but every time some one wins the GUI freezes.

class ListenerCA implements ActionListener {
public void actionPerformed(ActionEvent event) {
Board.clear();
if (turn == 0) {
start.answer = "CA";

[Code] .....

The code below this is the normal execution flow.

static void start_game(String board[][]){
final int one = 1;
final int two = 2;
int x = 0;
play game = new play();

[Code] .....

In the above code gui == true always, I just kept an option if i ever wanted to run the program in console. The code below is the restart method.

static void restartgui() {
gui = true;
if (gui ==true) {
board[0][0] = " ";
board[0][2] = " ";

[Code] ....

View Replies View Related

Create Hangman Game With GUI?

Apr 18, 2015

I am trying to create a Hangman game with a gui. i already have buttons for the letters, each with its own action listener. I'm having difficulties creating the gallows and man.

I have a class called guiTest, which contains all of the letters. This is essentially what i have. Can I add the image to this class, or do I need to create a new class that extends JFrame?

Java Code: import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Container;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JButton;

[code]....

View Replies View Related

Developing UNO Game In Java?

May 11, 2014

i can develop basic java programs but am not really good at it.I have been given this assignment of developing UNO game in java and have been given 10 days. How should i pursue and how should i start.I know the game rules.Do i need to learn swings for the same?

View Replies View Related

Multiplayer Networked Game

Jan 19, 2015

I already have a game, but I need to create a Socket(client-server) so that the game can be played by two players on a localhost.

View Replies View Related

Creating GUI For Game Of Life?

Dec 31, 2014

Here is my Code for the Game Of Life that I am programming to teach my self java. I am trying to create a GUI and I have done so and a window displays however i don't understand how i can get the Game of Life to display within that GUI?

import java.io.*;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.FlowLayout; //Provides default layout managing
import javax.swing.JLabel;
public class LifeMain extends JFrame

[Code] ......

View Replies View Related

Checkers Button Game

May 1, 2015

How do I track player (piece) movement?Building on the movement, to capture the piece you don't jump over it as in checkers, you move your piece onto the other color, so...How do I count pieces captured?

I'm really struggling on the physical code part. Conceptually I get that I need to store the information of each button clicked, but I don't understand HOW to store it, HOW to move a piece, and HOW to implement a system of turns.

View Replies View Related







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