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.
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:
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 ...
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.
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.
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.
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,
I decided to write a small Java program to experiment around with BorderLayout, because I'm developing a Java game and I need to have 2 objects placed in a single JFrame at the same time, and everyone I asked said I need BorderLayout to do that.Before you answer: Also, is using BorderLayout the best option for adding multiple video game oriented objects such a sprites to a JFrame?
So the Java program I wrote is supposed to place a JButton on the JFrame and ALSO place a graphic component (a rectangle in this case). The problem is, only the button shows up, as can be seen in the image link below: URL....
Here is the code:
**main.java** --> The main method class + JFrame/JPanel/JButton constructor import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class main {
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.
I have some problem checking if a directed graph has a cycle or not. So I have a given rooted directed graph, and find if there at least one existing cycle.
For example, I have to input the Root Node, followed by a number of nodes, the nodes in the graph, number of edges, and the adjacency list representing the edges. Each entry in the adjacency list contains a pair of nodes. The ordering of the nodes in the pair represents the direction of the edge. An entry A, B means that there is an edge from A to B. Nodes in each pair is separated by a space. One input per line.
And the output should display whether the directed graph has a cycle or not.
Sample input:
A //Root Node 6 //Number of Nodes A //Nodes in Graph B C D E F 6 //Number of edges A B //Adjacency list representing the edges B C C D C F F E E B
Output: Cycle!
Graph Representation:
Based on the illustration above, the graph has one cycle. The cycle exists in nodes B, C, F and E.
So I'm making buttons for a game I'm making. The graphics work, at least to the extent that I don't have to fix them yet. However, click detection is a bit iffy. For example pressing where the black line is in the first picture below, triggers a response. Now obviously that point is not on the button. I have tested the buttons bounding box by drawing a rectangle around it, using it's getBounds() method (which is also used for click detection) and it draws a perfect rectangle around it. So then I tested the mouse click points and it turns out that even though the button is placed at y = 100, at the black line, the mouse point is also equal to 100... Now, why that is happening, especially because, if I place the button in the top left corner, the mouse detection correctly detects the top pixels and there is no offset...
I need to be able to detect IE 9, IE 10, IE 11 and the latest from Firefox and Chrome. The old method using the user-agent string is unreliable and not recommended. There is a different approach called, "Feature Detection". But I need to know what features to test to determine the browser. I can write it myself, or if there is a handy dandy API using feature detection already written that would be OK too.
I'm new to java, and i'm trying to make a gaming, but for some reason nothing will print into the console. I want it to have the system to print out the frames, and ticks, but nothing will happen.
package ca.trey.game; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Dimension; import javax.swing.JFrame; public class Game extends Canvas implements Runnable {
I have a main class that hold the frame and paints, a class for drawing my game, and an image that is drawn too. I want to count the amount of times I click on this "android" (right now it counts if i click the screen) but the text from the class Game doesn't update.
androidX = Main.width - android.getWidth();
doesn't work. In my head the image should be inside the borders but it isn't. Have I calculated the pixels wrong or am I missing something?
public class Main extends JPanel{ public static final int width = 600; public static final int height = 600; Game game = new Game(); Android android = new Android(); public void paint(Graphics g) { super.paint(g); game.render(g); android.render(g);
I'm currently taking a computer program design class which has done a lot for my understanding of how to organize classes, but isn't giving me challenging enough assignments and I don't believe it's going to be covering interfaces and abstract classes, which is a shame. So I've been digging into these topics myself and decided to work on my own program (an Uno game program) that would utilize everything we've been learning and give me some practice with GUIs.
My current plan:
Have an abstract UnoCard class that determines the basic properties/methods common to all cards. Create a class for each card type extending from UnoCard, which would be - the generic card (number and color), action cards (skip, reverse, draw two), and special cards (wild, wild draw four, and blank).
Two enums, one for color, one for rank (which includes the numbers, as well as the action and special card ranks (reverse, wild, exc.) ).
A deck class would have an ArrayList <UnoCard> property and it's constructor would initialize a fresh deck.
A hand class that also has an ArrayList <UnoCards> where it gets said cards from the deck class.
A discard pile class, which contains the cards discarded and the current card in play.
A "board" class (haven't figured out a better name for it yet) which would determine/keep track of the number of players/hands, the turn order, the locations of the cards, and the winning condition.
Area of confusion and concern I'm having:
From what I've read, I want to avoid circular dependency. So if that's the case, when a card type effects the state of a "hand" or the turn order or really anything else, then in what class do I place the method(s) that effect that? If I place it in the specific card class, wouldn't that create a circular dependency? So would it be better then to have the hand class figure out what can be done with a specific card and what that specific card effects (which wouldn't that hinder the cohesion of the class?)?
I was also thinking a possible solution might be to have the non-generic card types contain methods that return values as apposed to manipulating higher level classes, such as a boolean drawCards which returns true if cards need to be drawn, false otherwise (same for skip, reverse, exc.).Then maybe the board class can determine what to do if those values are true or false (which actually seems more convoluted since only one value would be allowed to be true at any given time).
The other solution I was considering is to have a single UnoCardRules class, which serves the sole function of providing methods to determine the effects of each card, that way each card class can only worry about defining the card's state.
I wrote a program that would play a game of Hangman. It plays the game but it keeps on bringing up a exception error. This is my class code
import java.util.ArrayList; class Assignment2Q4 { private final ArrayList<Character> guessList = new ArrayList<>(); private final char[] charArray; private final String secretWord; private int guesses;
[Code] ....
This is the output that is given:
Enter the secret word: pizza Guess a letter: d ????? Guess a letter:
[Code] .....
Also when I guess the first letter of the word correctly it stops the program without going further on with the guessing.
I have panel = window(new frame) and its used to render a video image on, i need to pickup a touchscreen press change of event but not sure which event listener to use and on which component. Is it a panel, window or frame event? and which listener would detect a focus change or a mouse press
I know mouse listener and focus listener and window listeners are available but not sure they would be able to detect the screen press on the video rendered image...
So I'm doing a project for my CS class where we have to create a snowman doing something. My picture is of Vince Young in the 2005 Rose Bowl. I'm trying to make the actual video clip from Youtube (do I need to download it? If so I can do that) appear on the scoreboard, but how.
import java.awt.*; import java.awt.event.*; import java.awt.Font.*; class snowBackground { public static void drawField(Graphics g, Color field)
[code]....
There are 3 other files that make the actual Snowmen.Also, would I need to download the mp3 sound file seperately and play that, or will inserting the video do both?
So I'm doing a project for my CS class where we have to create a snowman doing something. My picture is of Vince Young in the 2005 Rose Bowl. I'm trying to make the actual video clip from Youtube (do I need to download it? If so I can do that) appear on the scoreboard. As of right now, this is my background file:
import java.awt.*; import java.awt.event.*; import java.awt.Font.*; class snowBackground { public static void drawField(Graphics g, Color field) { Color sky = new Color(95,166,243);
[Code]...
and this is the Driver file (not sure if this is necessary):
import java.awt.*; import java.awt.event.*; import java.awt.Font.*; public class SnowDriverWSB { public static void main(String args[]) { GfxApp gfx = new GfxApp(); gfx.setSize(1000,650);
[Code]...
There are 3 other files that make the actual Snowmen. To do this, I need VERY basic steps, as I'm extremely confused and new to Java. Also, would I need to download the mp3 sound file seperately and play that, or will inserting the video do both?
I am trying to make an encrypted video chat program using JMF. I have successfully written the "video chat" part - which includes getting data from webcam and transmitting it using RTP, but how to get raw data video to encrypt it before it stream between the webcam and the network.
For RTP I am using RTPManager, and for reading from the webcam I am using this code:
DataSource ds; CaptureDeviceInfo di = null; StateHelper sh = null;System.out.println("Started Video"); String str1 = "vfw:Logitech USB Video Camera:0"; String str2 = "vfw:Microsoft WDM Image Capture (Win32):0"; String str3 = "vfw:Microsoft WDM Image Capture (Win32):0 : vfw://0";
[Code] .....
I plan on using a stream cipher for encryption, maybe RC4.
How to insert and play a video or a music background in a java application. Let me explain better... I need to develop a game where sometime I need to show picture, or play videos and also, if is possible, add a music in background... I work with eclipse and I know quite good the main concept of java's language...