Create A Simple Dice Game Java Eclipse Android

Jan 8, 2015

The game is too have two players, each user clicks a button and two dices will roll, if a user rolls a double they win.

firstly I have started with two imageview's and a button I am trying to randomise two images by clicking one button I have managed to randomise one image in one box but I am struggling to randomise both image views here is my code so far.

import java.util.Random;
import android.app.Activity;
import android.os.Bundle;

[Code]....

That code is only generating a random dice image in one of the image views I have hit a brick wall

View Replies


ADVERTISEMENT

Android Eclipse Home Game Poker

Sep 1, 2014

I'm trying to create a Texas hold'em Poker application. A rough idea of it would be similar to those poker games on the playstore e.g. Zynga Poker, however it will be a simplified version, more of a home-based application, for a small group of friends. This way, we can get to play poker on the go with each other, like a private table on the go. Anyway, right now how do I get started?

1) How should I even start this project? Do I start the GUI for the application first? Start designing the applications with photoshop? I figured I need a skeletal guide to start and follow.

2) How do I connect all the players together to a table? I know I could use my phone as a Server, where the rest could connect to mine. But I'm not sure what I should research on. Also, as I'm working towards a "Portable, On the go Application". So I would like to work this more based on 3G/4G networks.

3) Database, I would like something to keep a record on the buy-in, winnings & losings so we can keep track of it. However, if the server was my phone. When I turn off the server, would the database be gone? Maybe I might be able to save it on a notepad in a folder on my phone? I think this is possible.

View Replies View Related

Simple Program In Java (Eclipse) That Converts Fahrenheit To Celsius

Apr 10, 2014

I've made a simple program in Java (Eclipse) that converts Fahrenheit to Celsius.The class is:

Java Code: package ehu.student;
public class ConversorTemperaturas {
/*--------------------------------------------------------------*/
/*Clase que dado una temperatura en Fahrenheit la canvierte en C*/
/*--------------------------------------------------------------*/
public float farenheit2celsius (float d){
float celsius, aux;

[code]...

When I write t.farenheit2celsius(25.6), appears the following error: "The method farenheit2celsisus(float) in the type ConversorTemperaturas is not applicable for the arguments (double)"If i change in the class the type float for double there is not problem. Why can't i use the type float?

View Replies View Related

Eclipse Android - How To Go From 2nd Activity To 3rd Using Buttons

Feb 8, 2015

I didn't see anything specific to Android. I am a very basic beginner when it comes to JAVA and Android programming.

The app is a very simple comic strip viewer that views 3 panels of a comic strip one at a time. My problem is going from a second activity to another. I can go from the main activity to the second fine but when I press the next button to go from the second activity to the third nothing happens. I have tried a few different things but end up with either nothing happening or the app crashes.

Here is my MainActivity Code:

package net.androidbootcamp.comicapp;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

[Code]...

Here is the code for the second panel:

package net.androidbootcamp.comicapp;
import android.app.Activity;
import android.os.Bundle;
public class Panel2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {

[Code]...

Here is the code for Panel 3:

package net.androidbootcamp.comicapp;
import android.app.Activity;
import android.os.Bundle;
public class Panel3 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {

[Code]...

And here is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[URL].."
package="net.androidbootcamp.comicapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk

[Code]...

I am sure it is something very simple but I am not sure what it could be.

View Replies View Related

Java Game In Eclipse Mouse Not Moving

Apr 24, 2015

try to make a game in this code i am trying to make the basics i have made a mouse it should move the game code is

import java.applet.Applet;
import java.awt.*;
public class Game extends gameLoop {
public void init()
{
setSize( 854 , 480);
Thread th = new Thread (this);

[code]...

View Replies View Related

Simple Java Game - Moving Icon That Is Controlled Using Keyboard

Apr 1, 2014

I am writing code for a simple java game. The problem I am running into is that I have a moving icon (J button) that is controlled using the keyboard (arrows) and I also have stationary icons (J button). Is there a way to keep the moving icon from passing over the stationary icon? I would like the stationary icon to act like a wall.

View Replies View Related

Make A Simple Platformer Game In Java - Moving Characters

May 24, 2015

I am trying to make a simple platformer game in Java. When I try to move the character I made it only moves over then immediately back

import java.awt.event.KeyEvent;
public class UCC
{
private int xLoc;
private int yLoc;
private int xSpeed;
private int ySpeed;
private double gravity;
private int size;
 
[code]....

View Replies View Related

Random Dice Roller Game

Oct 23, 2014

So far I have

import java.util.Random;
import java.util.Scanner;
public class DiceGame6 {
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
System.out.println("Welcome to Computer Dice!");
System.out.println("-------------------------------");
System.out.println("You will first roll your dice

[code]....

How would I get the code to count the number of times something occurred. In the end it's suppose to count how many times I played the game and how many times I've won vs lost.

View Replies View Related

Android Game - Record A Single Click

Nov 7, 2014

I'm making a game to teach myself programming java so I can start making android. I have this game I'm making where there will be objects(so far its asteroids) will be falling with a progressive velocity (they will move faster as time goes on). The object is the click on the objects before they hit the bottom. It's still early meaning not all the parts I want to implement are there but it works the way I want it to so far besides my click function.

I'm using the Mouse.isButtonDown(0) to record left click but It lets me hold it down and hover over them instead of clicking on each one. Here is a snippet of the part of the code im talking about :

I uploaded a .jar and a exe file so you can see what I mean
[URL] .... -jar
[URL] .... -exe

public void update(GameContainer gc, int d) throws SlickException
{
posX = Mouse.getX();
posY = (Mouse.getY()-height)*-1;
timePassed += d;
deltaTime= deltaTime();

[Code] .....

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

GUI Dice Game Compilation - Cannot Find Symbol Error

Nov 29, 2014

I'm having some difficulty getting this GUI dice game to compile. I'm using javac and notepad++ for this and I'm getting the following errors:

DiceGame.java:34: error: cannot find symbol
die2label = new JLabel();
^
symbol: variable die2label
location: class DiceGame

[Code] ....

4 errors

My code is as follows:

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class DiceGame extends JFrame

[Code] ....

I'm sure the problem is something trivial, but I guess that's all part of the learning process that I have to go through.

View Replies View Related

How To Create A Box To Hold Text Below Google Maps Within Android

Feb 19, 2014

At this point I know how to utilize Google Maps within Android but it always seems to take up the full window, there is an image below which shows what I'm attempting to accomplish (having a box below the Google maps where I can store text i.e. "Hello World"

How do I add box below Google Maps, so to store text i.e. "Hello World"

Code so far:

ActivityMain:

Java Code:

public class MainActivity extends Activity {
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

[Code] .....

Image:

View Replies View Related

Create A Class Called Dice To Represent SINGLE Cube

Apr 15, 2014

I need to work on this "Dice" program. I've done it twice already. I've also been pouring over examples on here and elsewhere online, but none of them exactly match what I'm doing, as they all say "Pair of Dice".Mine says: "Create a class called Dice to represent a SINGLE cube". It should have a method called roll() that randomly selects a number from 1-6 for the value of the dice."

It has to use java.util.random, not math.java, and it has to have numberShowing:int, roll():int, and main() all in it.The last part reads "Create a test main method for the Dice class that creates a dice and rolls it many times. Can you keep track of how many times a number comes up? Describe how or implement it in the program." I have started at this computer for hours, and read as much info as I can.

View Replies View Related

Multi-sided Dice - Keep Track Of Total Sum Of All Dice In Array

May 7, 2014

I'm finishing up this assignment, and I'm stuck. These are the last 2 instructions:

. Roll each of the Dice by invoking the roll method on each Dice in the array.
. Keep track of the totals sum of all the dice in the array. Be sure to roll the dice array at least 10000 times.

How to finish it up?

Here's my code so far:

package homework3;

import java.util.Random;
public class Dice {
private int numberShowing;
private final int numberOfSides;
private static final Random randomNumber = new Random();
public Dice() {
numberOfSides = 6;

[Code] ....

View Replies View Related

Dice Game - Invoking Method In Other Method Of Same Class

Feb 26, 2015

I am currently working on a dice game. I have a private method called rollDice and it performs the action of rolling two dice. For my project, I need to create another method called playerRolls and I am supposed to invoke the rollDice method in the playerRolls method and perform actions based off of that. My question right now is how do I invoke a method into another method of the same class?

View Replies View Related

Simple Ping Pong Game

Jul 14, 2014

When I ran the methods "go1,go2,go3" separately without clicking on the menu , all of them worked well. by separately I mean, when I closed the program changed the source code from "go1;" to "go2" and go3. But when I click on the "change ball" and then "1 ball" or any thing, all I get is a new frame which is blank. And the old frame freezes.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author Administrator
*/

[code]...

View Replies View Related

Simple Snake Game - Timer And KeyListener

May 25, 2014

I'm trying to create a simple snake game, but I can't get my timer and keyListener to work...

//Timer
Timer tm = new Timer(5, this);
int x = 50, y = 250, vel = 2;
// The snake
g.setColor(Color.black);
g.fillRect(x, y, snakeSize, snakeSize);

[Code] .....

View Replies View Related

Simple Cannon Game - How To Delete Objects

Oct 22, 2014

I am using libgdx and box2d to try to make a simple cannon game.

When I have the cannonball collide with another object I want to delete that object and have it stop calling all of it's functions. It doesn't seem like I can have it delete itself, and the contactListener has a reference to the cannonball and other object, but if I set either to null, it seems the original reference still exists and the object isn't deleted.

View Replies View Related

Simple Pong Game - Touch Red Block

Dec 27, 2014

I don't know how to write a code to pong ball, when it touch red block.

public class bounc2 extends JPanel implements ActionListener,KeyListener{
double x = 0,y=0,velX=3,velY=3;
double x2 = 5,y2=145,velX2=0,velY2=0;
double x3= 473,y3=145,velX3=0,velY3=0;
Timer t = new Timer(5,this);
public bounc2(){
setBackground(Color.GREEN);

[Code] .....

View Replies View Related

How To Prevent A User From Going Out Of Bounds In Simple Array Game

Apr 26, 2015

I am making a very simple 2D array game where the player is asked what size they would like the game board to be. After entering, it displays the board and the player 'P' starts at index [0][0]. After that, they are asked for an action, which can be "up", "down", "left", "right", or "exit". I will be including some extra later (like a treasure at the end, or random obstacles), but for now this is what the game consists of.

I was instructed to "do nothing" when/if the player attempts to go out of bounds. I am trying to simply print an error, such as "Out of bounds! Try again.", then prompt the player again for an action. I even tried to make a boolean method to catch it, but to no avail.

I don't want the exception to occur at all. I just simply want the error message to print to the player and ask for another action. I would prefer not to use try/catch, or try/catch/finally since I already tried that and it still gave the exception error.This program consists of two classes. I will show the class containing the main first, then the client-server type class second.

import java.util.Scanner;
public class Driver {
public static void main(String[] args) {
World world = new World();
boolean keepPlaying;
keepPlaying = true;
boolean isOutOfBounds;
isOutOfBounds = false;
int height = 0;
int width = 0;
int x = 0;
int y = 0;

[code]....

View Replies View Related

Create A Simple GUI With One Button That Just Says Play

Feb 25, 2014

I am new to Java, I am using Netbeans to create a simple GUI with one button that just says "play". I want this to play an mp3 file i specify. I have found code to simply play a WAV which works great.There is lots of information on the net about playing an mp3 but it's all long an complicated. There must be a simple way to just have java play an mp3 file.

View Replies View Related

Trying To Create A Simple Class In Netbeans

Mar 17, 2015

I'm new to java and trying to learn the ropes on Netbeans!What I want to do is make a class which does the following

-Asks for and reads a first number on the command line.
-Asks for and reads a second number using a JOptionPane
-Asks for and reads your name using a JOptionPane

I want it to output the name and the remainder of the first number divided by the second number.

View Replies View Related

Swing/AWT/SWT :: Create A Simple JFrame Application

Jan 22, 2015

I installed Windowsbuilder in Eclipse as described in this video:URL....

To get starated I now want to create a simple JFrame application that works in the following way. On the opening screen I want to present 4 buttons. Based on the selection I want the JFrame to change layout and components so that the same JFrame behind the scenes contains 5 layouts but only one visible at any time. What is the best way to accomplish this? Or should I do this in another way using multiple JFrames or similar?

View Replies View Related

Value Of Variable In Java - Android Studio

Jun 4, 2014

I have an integer variable called 'selectedname' which is declared as shown below.

public class MainActivity extends Activity implements View.onclickListener, AdapterView.OnItemClickListener {
int selectedname;

So when the app starts an Alert Dialog with two buttons asks the user if they want to tell the first or the last name. The two buttons are 'first' and 'last'.

The problem I'm facing is that in the code the value of selectedname is suppose to change depending on the users choice as shown below.

public void displayWelcome() {
//*other code comes here but it works fine*
AlertDialog.Builder choice = new AlertDialog.Builder(this);
choice.setTitle("Yo!");
choice.setMessage("First name or last");
choice.setPositiveButton("First", new DialogInterface.onclickListener() {
public void onclick(DialogInterface dialog, int whichButton) {
selectedname = 1;

[Code] .....

View Replies View Related

Implementing Java Project With Android

Nov 19, 2014

I have a gameengine stil partially in the works for pc made in java, I am attempting a port over to java but certain classes and other fuctions are not available for android that there is in java. this means that my render engine, gameengine and a couple of other clases therefore don't work.

My question is, is there anyway of using the gameengine classes that work into the project so that all i have to do is declare within the engine what i want to export for wheather this is android or java. or importing packages from the game engine project and directly linking with the ability of re-writing the odd few classes that do not work.

View Replies View Related

How To Return A String From Java To Android Project

Jun 26, 2014

I tried many times to return a string from java project to an android project But it keeps sending incorrect values as in as it should be 1 here is an example.

Java Project:

boolean somethingboolean = false;
if(something == "1"){
somethingboolean = true;
}
public static String getString(){
if(somethingboolean == true){
return "TRUE";
}else{
return "FALSE";
}
}

Android project:

System.out.println(JavaProject.getString())

And in the android project it prints "FALSE"

So what should i do?

View Replies View Related







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