Frames Per Second In Games
Nov 13, 2014
I have a question about Frames per second in games. In a simple game i should be able to pull off 60(exactly), right? So if i have this code for a game loop:
while(shouldRun){
Thread.sleep(1000/60);
//loop code here
}
will that run at 60 fps?
The loop code takes a tiny bit of time, then it waits for (a second/60), so overall the code will be running overall since the code takes some time?
Is this the case , and if so is there a solution?
View Replies
May 27, 2014
I've been doing a course with a heavy focus on applets and AWT using BlueJ. I've branched out and learn to convert my applets to applications. I can successfully use frames to do similar things to applets (in BlueJ's applet viewer) but I can not seem to run more than application at a time (unlike applets where I could run several at the same time).
Below is a simple Hello World program I wrote. When I re-run main() it closes the original and starts again. (I'm aiming to explore the java.net.* libraries and for testing would like to use more than one frame at a time which can communicate to each over via sockets).
import java.awt.*;
import java.awt.event.*;
public class HelloWorld extends Frame implements WindowListener {
public static void main (String[] args) {
HelloWorld app = new HelloWorld();
app.setSize(500,500);
[code]....
View Replies
View Related
Apr 3, 2014
i want to know how i can add more than one frame in a single frame means main window or frame will be constant and only components will be chang or vary as in a software or game .
View Replies
View Related
Oct 20, 2014
I am working on this experiment code, I keep getting an exception:
run:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -256
at .MemoryManager.read(MemoryManager.java:68)
at .MemoryProcess.callMemory(MemoryProcess.java:39)
at .main(Lab3.java:29)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
The offending line is data=RAM[physicalAddress]; inside MemoryManager.java.
why this is exactly happening and thus correct my piece of code.
The code:
main.java
package experiment;
public class Main{
/**
* @param args the command line arguments
[Code].....
View Replies
View Related
Nov 23, 2014
building a game. the game is all about the multiple times table with levels. easy medium and difficulty. I dont even know where to begin and what is the codes to use or even the platform. what websites can be access etc and what is the big deal with code tags.
View Replies
View Related
Jan 13, 2014
I developed a simple java gui . On running a frame opens with 5 buttons and each button opens another frame when selected. There are no errors and frames open and close as required however i see that only the main program frame has the icon and title that i assigned and the frames bieng called through the buttons have the default frame with java icon and no title although it's been specified in the code of these called frames. When these called frames are executed individually though the program the title and icon are displayed.
View Replies
View Related
Aug 22, 2014
/*
/ GuessGame.java
*/
import java.util.Scanner;
import java.util.Random;
public class GuessGame {
public static void main(String[] args) {
[code]....
tracking the number of games played, and also when running the code, I have to press "1" twice for it to actually load up the game again.
View Replies
View Related
Jul 24, 2014
I am having a problem with my java program. My goal is to request the user to enter how many times they want to roll a pair of dices. Each dice have numbers 1-6. When rolling the dices, I randomly pick a number from each dice and total the number. My goal is to calculate the number of times snake-eyes was rolled which is a total of 2 and total number of times a total of 7 was rolled. Here is my code. I am calling the rollDice method to perform the random pick and calculations. The error I am getting is at the bottom of the code.
package dice;
import java.util.Scanner;
import java.util.Random;
public class Dice
{
public static void main(String[] args)
{
int numRolls; // number of rolls
[code]...
How many times would you like to roll the two dice? 1000 Exception in thread "main" java.lang.NullPointerException at dice.Dice.main(Dice.java:40)
Java Result: 1 BUILD SUCCESSFUL (total time: 4 seconds)
View Replies
View Related
Jun 6, 2013
I am unable to open Pogo Poker with out receiving an error message saying "Oops, Java is not detected on your computer" (or something similar). I have reinstalled it several times and get the same results.
View Replies
View Related
Dec 3, 2014
I was developed a simple GUI, in that it requires modification of jtextfield content while JComboBox item selected and vice-versa. I was used itemListener on JComboBox and Document Listener on JTextField. It was gives exception while running the code. Because one listener source effected by another one..
Exceptions are like this:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Attempt to mutate in notification
at javax.swing.text.AbstractDocument.writeLock(Unknown Source)
at javax.swing.text.AbstractDocument.replace(Unknown Source)
at javax.swing.text.JTextComponent.setText(Unknown Source)
at ronanki.swing.pcahostsimUI$5.itemStateChanged(pcahostsimUI.java:368)
at javax.swing.JComboBox.fireItemStateChanged(Unknown Source)
[Code] ......
View Replies
View Related
May 25, 2014
So I am working on a database pertaining FCBarcelona. I have three classes FCBarcelona.java Player.java and Roster.java
I am working on a method that updates the number of games played by the player ... Its not working it gives a runtime error ...
Roster.java
public Player changeNumGamesPlayed(Player nPlayer)
{
int index = play.indexOf(nPlayer);
if(index == -1)
return null;
[Code] .....
View Replies
View Related
Jul 14, 2014
HTML Code:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.imageio.ImageIO;
public class Main extends JApplet implements Runnable, ActionListener {
[Code] .....
I am making a game and there are two problems that I have and can't seem to solve. I never made on applet before, and I'm not good with the swing components, but I am decent programming in Java.
Problem #1: the start button is in the JPanel, I don't want that, I want it to be above the JPanel.
Problem #2: I want to put images in to a JTable for organization and character selection purposes, but I keep on getting a string. Do I have to use an ImageIcon to get it to work, or does it matter?
In case you were wonder what kind of game I'm making, I'm making one of those jump games where you jump on platforms and try to go as high as you can without missing a platform. There is going to be character selection for the jumper, and the jumpers are going to be food, like a potato, a banana, a strawberry, etc.
View Replies
View Related