JAVA Platform Game Jumping And Collision

Sep 16, 2014

i have problem in what comes to jumping because in what i have now mario jumps with the key lsitener, key pressed up arrow and it jumps smooth but when im trying to make it fall down he appears immediatly at ground and it doesnt simulate the fall as it should be.

import java.awt.BorderLayout;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.awt.EventQueue;

[code]....

The other problem is that i dont really know how to detect collisions if there is a method that makes easier this proceso and how to make the map to continue and repeat so mario could continue walking,

View Replies


ADVERTISEMENT

Pong Game - Y Axis Collision Detection

Jan 28, 2014

I have made a "Pong" game and how to check if the ball has hit the top or the bottom of a paddle, however I do know how to check if it has hit the left or right side:

Java Code:

if((BALL.getX() >= LEFT_BAT.getX() && BALL.getX() <= LEFT_BAT.getX() + LEFT_BAT.getWidth()
&& BALL.getY() >= LEFT_BAT.getY() && BALL.getY() <= LEFT_BAT.getY() + LEFT_BAT.getHeight())
&& (BALL.getX() >= RIGHT_BAT.getX() && BALL.getX() <= RIGHT_BAT.getX() + RIGHT_BAT.getWidth()
&& BALL.getY() >= RIGHT_BAT.getY() && BALL.getY() <= RIGHT_BAT.getY() + RIGHT_BAT.getHeight())){
BALL.increaseDX();
BALL.setDX(-BALL.getDX());
} mh_sh_highlight_all('java');

It seems as though I would use the same code for checking the top or bottom.

View Replies View Related

Video Game - Collision Detection Class?

Apr 30, 2014

I use eclipse as my IDE. I have decided to make my own video game and somebody had sent me a class that could be used for collision detection. The problem with the collision detection class was that it made a box around an object and if something else had touched the object, the collision detection would work. My problem with this class is what happens when i want to use circles? I cant have a box drawn around it. Then it wouldn't work as i would want. Is there a pixel perfect collision detection class out there I can use? It'll be useful in my journey to become successful in computer science! By the way this is in the java language.

View Replies View Related

Space Invaders Game - Collision Detection

Apr 19, 2014

I'm working on a space invaders game and I'm having problems with collision detection. My main issue is I'm having problems getting what the y value of the "missile" is as it goes up towards the top of the game. I have tried for many hours and tried to look at other people's space invaders game in an attempt to figure out how to figure out my problem. Also I'm not sure if I have the code for my collision detection in the correct spot. Right now I have the code in the keyPressed method. Below is the code for the main and missle classes ...

import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Iterator;

[Code] ....

View Replies View Related

NoClassDefFoundError With Java Standard Platform Class?

Feb 18, 2015

I am facing NoClassDefFoundError with one of the java standard platform class (java.text.DigitList$1)

java.text.DigitList class is part of rt.jar so it should not create any issue as such.

I am using Java 1.6.0_06

StackTrace:
Unhandled exception java.lang.NoClassDefFoundError: java/text/DigitList$1
at java.text.DigitList.shouldRoundUp(DigitList.java:4 11)
at java.text.DigitList.round(DigitList.java:363)
at java.text.DigitList.set(DigitList.java:351)
at java.text.DigitList.set(DigitList.java:272)
at java.text.DecimalFormat.format(DecimalFormat.java: 584)
at java.text.DecimalFormat.format(DecimalFormat.java: 507)
at java.text.NumberFormat.format(NumberFormat.java:26 9)

View Replies View Related

How To Display SWF Files In Java Code JEditorPane Using Eclipse Platform

Apr 28, 2014

Here attached my java code am trying to display .swf or .fla files from this code but am not able to retrieve .swf or .fla files.

View Replies View Related

Swing/AWT/SWT :: Printing JTable - Java (TM) Platform SE Binary Has Stopped Working

Nov 19, 2014

I am getting the following message when trying to print a JTable.

"Java(TM) platform SE binary has stopped working"

Here is the code:

try {
MessageFormat headerFormat = new MessageFormat("Page {0}");
MessageFormat footerFormat = new MessageFormat("- {0} -");
table.print(JTable.PrintMode.FIT_WIDTH, headerFormat, footerFormat);
} catch (java.awt.print.PrinterException pe) {
System.err.println("Error printing: " + pe.getMessage());
}

View Replies View Related

Dead On Collision

Jun 15, 2014

okay so far I have made a game with character that runs with constant velocity it jumps and ducks . I want the player to be dead on collision from a hurdle and then play a specific png, which shows the dying style . I am able to build collision detection but it passes from background I want it to collide and be dead on collision.

View Replies View Related

RMI With Doing Calculations Across A Server / Client Platform

Apr 6, 2014

It's an RMI program that has to be able to return the mean, mode and median of a set of numbers.It's composed of 4 classes; a client, an implementation class (with the math), an Interface, and a server class.

import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.io.*;
 
[code]....

View Replies View Related

JavaFX 2.0 :: Point Of Collision Between Shapes

May 25, 2015

I have a problem in with colissions in JavaFX.
 
First, I detect a collision between a line and a circle using the follow code:
 
if(line.getBoundsInParent().intersects(circle.getBoundsInParent())){
System.out.println("Collision!");
}
 
After this, i need catch the coordinate of collision, like the below figure:

How to catch this coordinate?
 
[]'s

View Replies View Related

Object Collision Detection - Character Freezes

Dec 2, 2014

I don't understand why when I collide into my objects my character freezes. Such as if I collide into collision() I can go left and right but, not up and if I collide into collision2() I freeze in all places but, if I collide into the bounds I made I can still go in all directions without problems. The xa and ya are still being set to 0.

package com.questkings.game;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;

[Code] .....

View Replies View Related

Unable To Keep Platform Object Within Applet Window?

Jun 12, 2014

I created a simple java game in which i have to keep the ball up with a platform, similar to the game brick breaker. Everything works great. I am using keyListener to move the platform left and right. My only problems is that I am unable to keep the platform in bounds of the applet window. I know Its something to do with my logic in the update method of my Platform class but I'm stumped. Here are the 3 classes:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

[Code].....

View Replies View Related

Difference Between Terms - Architecture Neutral And Platform Independent

Aug 12, 2014

I have just started learning Java from a local teacher, this teacher said that the Architecture Neutral refers to Hardware while Platform Independent refers to Operating System, but I found a link to a White Paper by James Gosling. The chapter 4 of this White Paper mentions about both binary code format that is independent of hardware architecture and operating system interfaces, but the main point to be noted is that he has put both under the heading Architecture Neutral. Does it mean that the original buzz word is Architecture Neutral, which includes both hardware and operating system independence?

View Replies View Related

Collision Detection Using Rectangles - Player Sometimes Passes Through The Tiles

May 19, 2014

I have already tried every possible way for removing this bug but all failed. The problem is that sometimes my player passes through the map tiles, i mean, the algorithm is like -- if not colliding, move in required direction; else if colliding, move in opposite direction. But sometimes the second condition fails i dont understand why.

private void movement(){
left=bindObject.getLeft();
right=bindObject.getRight();
up=bindObject.getUp();
down=bindObject.getDown();
bindObject.setColliding(colliding);

[Code] .....

Where bindObject is a class which contains key bindings of following keys:-

left arrow key (when pressed) , left arrow key (when released),
right arrow key (when pressed), right arrow key (when released),
up arrow key (when pressed), up arrow key (when released),
down arrow key (when pressed), down arrow key (when released)

View Replies View Related

Counting Scoreboard - How Many Times A Ball Hits Moving Platform In Pong

May 9, 2014

I need to make a scoreboard that can count how many times a ball hits a moving platform in pong and have no clue how to approach this.

View Replies View Related

Unable To Detect Collision Between Moving And Stationary Jbuttons Using Rectangle Intersection

Apr 5, 2014

I am trying to detect the collision between a moving Jbutton and stationary Jbuttons using Rectangle Intersection.

When I run the program I am getting a NullPointerException on line 'msg1.setBounds(new Rectangle(320,50,400,50));'.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class gamePanel01 extends JPanel implements KeyListener {
character ch1 = new character("Hero");
//Global Variables
JButton blocker01;
JButton blocker02;

[Code]...

View Replies View Related

BlueJ Platform - Conversion Program From Cm To Inches And Inches To Cm

Jan 20, 2015

I am coding for the first time using the simplified BlueJ platform. I am trying to write a simple conversion program from cm to inches and inches to cm.

Here is my code so far (I also have the textIO file linked to it):
 
public class UnitConverter {
public static void main(String[] args){
int inchesTocentimetres, centimetresToinches, exitApplication;
int choice;
double result;
 
 [Code] .....

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

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

Java Game Creation

Jan 26, 2015

I am creating a simple tiled minecraft like game in java, but i dont know how to make the game loop.Here is the source:

package net.pltformgame.main;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class main extends JFrame implements KeyListener {

[code]...

I really dont know how i make the jump or the game loop.

View Replies View Related

Java Game Health

Jan 20, 2015

I'm building this custom project in stages, and I'm having difficulty getting the health of the player and the enemy to change. Upon compiling, I'll select weapon 1, then choose action 1 (basic attack), and the health of both the player and the enemy will stay at 15 and 10.There are no errors when compiling.

import java.util.Scanner;
public class CustomProject
{
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
it hp = 0;
int potionsleft = 0;
int choice1 = 0;
int weapon = 0;
int enemy1hp = 10;
//int newenemy1hp = 0;

[code]....

View Replies View Related

Java Matching Game

Apr 14, 2015

I'm working on a Java matching game and I'm having a hard time wrapping my mind around it. What I'm having trouble with is how exactly to create an array so that my squares have random values. Then how do I get it to reveal and compare those values by clicking on two of them? Here is what I have so far:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

[code]....

View Replies View Related

Coding AI Game Through Java

Apr 10, 2015

The game has two players: x and o. The players take alternate turns, with player x moving first at the beginning of each game.

Player x starts at position (1,1) while o starts at (8,8).

Each turn, a player can move like a queen in chess (in any of the eight directions) as long as her path does not cross a square already filled in or occupied. After moving, the space vacated by the player is designated as filled and cannot be moved to again. Notice that only the space that was occupied is filled, not the entire path.

The game ends when one player can no longer move, leaving the other player as the winner.

The coordinate (1 1) indicates the top left hand side of the board.

The board is specified as a list of rows. Each row is a list of entries:

- is an empty square * is a filled in square x is the current position of the x player o is the current position of the o player

The board will always be 8 by 8.

Your player function should take in the parameters as described above and return a move as a list in the format (row column) within 1 minute. If you cannot move, return (nil nil). The Tournament Referees will check for this. If you return an illegal move, the other player (and the Tournament Referees) will detect it and you will lose.

Additionally if your time expires you will lose.

View Replies View Related

Tiled Based Map Game In Java

May 10, 2014

I'm trying to create a tile based map JPanel but all I get is a white screen. I'm fairly new to the Java Swing and AWT package so I've been watching tutorials on YouTube so learn as much as I can.

I've got three classes: Window.java which includes the Main method, Panel.java which is the JPanel and Tile.java to draw all the images into an array.

Window.java:

import javax.swing.JFrame;
public class Window extends JFrame {
public Window() {
setTitle("Project");
setSize(500, 400);

[Code] .....

I've checked through everything and still cannot find what I'm doing wrong. I did try different codes but I just got errors instead.

View Replies View Related

How To Improve Battleship Game Java

Dec 3, 2014

I have an battleship program that I would like to improve in performance. I know that using certain algorithms it can be improve however I am beginner in Java. I would like any recommendations and or hint in how to improve this game. The are 5 ships per game and the computers plays 10000. I just want to sink all ships in as many shots as possible.

Main class

package solution;
import battleship.BattleShip;
import java.awt.Point;
import java.util.List;

[Code] .....

View Replies View Related

Make A Connect 4 Game With Java

Nov 17, 2014

I have to make the connect 4 game be connect 3. Ive edited a code but I the math is over my head. These loop methods check the ways someone can win.

for (int j=0;j<7;j+=2)//need to change
{
if ((f[i][j+1] != " ")
&& (f[i][j+3] != " ")
&& (f[i][j+5] != " ")
&& (f[i][j+7] != " ")
&& ((f[i][j+1] == f[i][j+3])
&& (f[i][j+3] == f[i][j+5])
&& (f[i][j+5] == f[i][j+7])))
//end of loop

[code]....

View Replies View Related







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