Fading Trail And Random Movement Coding?
Oct 30, 2014
I need the following key controlled ellipse to leave a trail behind that vanishes after 10 frames. Also, I need to create a random moving ellipse not related to the preexisting one. How to separate the two ellipses ...
Current code:
boolean left, right, backward, forward;
boolean SPEED;
PVector pos = new PVector(680, 400);
void setup() {
size (680,400);
fill (0 ,0,0);
frameRate(100);
noCursor();
[Code] .....
View Replies
ADVERTISEMENT
Feb 11, 2014
I have been working on this mouse movement code that detects which direction the mouse moves in hope to use it in a game. The only problem is that I can not figure out how to make it move to the other side of the screen so I could continue turning to the right or left without having to stop. How would I actually get the x and y coordinants of the mouse to change?
PHP Code: if(x == xscreen){
//set x to 0
}else if(x == 0){
//set x to xscreen
}else if(y == yscreen){
//set y to 0
}else if(y == 0){
//set y to yscreen
} mh_sh_highlight_all('php');
View Replies
View Related
Jan 23, 2014
First, I have a figure that moves around the screen. It uses keylisteners and just subtracts or adds pixels. However, I notice the movement is not smooth at all. It is very rigid and laggy movement. How can I make it smoother movement?
Second, you get three lives in the game. The lives are subtracting correctly, but I want the game to say "GAME OVER" on a dialog box. How would I get this to happen? My JFrame and my life int are in separate classes. I know I should use an if statement, saying if lives are at or less than zero, open the box, but how do I open the box?
Third, I want to display the time on the screen. I have a swing timer, but how do I put it on the screen? DrawString is not working for me.
Fourth, I want to set an icon for the game, the code is running, but not doing anything.
Java Code: frame.setIconImage(Toolkit.getDefaultToolkit().getImage("/Users/MW/Downloads/petericon.jpg")); mh_sh_highlight_all('java');
View Replies
View Related
Dec 8, 2014
The program I'm supposed to create generates a random number between one to ten. Then the program is to ask me if I wish to cross the road. If you choose to cross, the outcomes for 0-2 are "You crossed safely." For 3-5, 75% of the time it should say "RIP you got run over", and 35% of the time it should say "You crossed the street." For 6-8, 60% of the time it should say you made it.", and 40% of the time it should say "You died". For 9-10, it should say "RIP".
So far I have gotten the random number generation part working. I have up to here:
import java.util.Random;
public class test4 {
public static void main(String[] args) {
Random random = new Random();
for(int i =0; i < 1; i++){
int num = random.nextInt(10) + 1;
System.out.println("The number of cars on the street are: " + num + "Do you wish to cross the road?");
}
}
}
View Replies
View Related
Feb 13, 2015
I'm relatively new to Java, I'm trying to create a text based game, like those old ones where you type "north" or "east" to move as such, and "look" to inspect the area. My only problem thus far has been trying to figure out just how I should... "structure?" the movement. As in, what's the best overall way to approach this? I've tried making a new method for every area and just passing a variable called "location," but along with passing the inventory and stat arrays, it's just become messy. Or is this a good way to do it? I have a separate method for when the player enters something, but then how will it know which description to give when the player types "look?"
View Replies
View Related
May 28, 2014
I am new to DreamInCode! I was creating a game using OpenGL (and slick for textures).
Using Vector3f, I make coordinates to where my camera is camera'ing (and rotation).
It was working... until I modified something. I only added shaders. When I took the shaders off I think I might of accidentally deleted something. Nonetheless the code looks perfect to me.
On the method "input()" everything runs. No errors are thrown anywhere. I have syso'd the hell outa my code. It shows no signs of breaks. I can, however, move elements I put into my program. I am 100% sure that no other class is breaking my game (soon to be).
What you should look out for: I am not really sure about the glLoadIdentity()'s and glMatrixMode(). I am, knowing a good part of, thinking it could be gluViewPort....
My problem: Can't move my camera even tho it was working before.
package com.Hydroque.OpenGlTest;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.gluPerspective;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
[Code] ....
View Replies
View Related
Jun 16, 2014
I am working on replicating this project: [URL] ....
What is wrong with the moveSnake method and the for loop within it?
View Replies
View Related
Aug 31, 2014
I just started to learn Java. In my program, I created a GRect(paddle) and I would like to move it on the x axis whenever the mouse is moved.
import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.awt.*;
import java.awt.event.*;
public class BreakoutClass extends GraphicsProgram {
/** Width and height of application window in pixels */
private static final int WIDTH = 400;
private static final int HEIGHT = 600;
[code]....
In this case, whenever the paddle reaches the right edge of the screen, it doesn't move off the windows, but it stops moving (even if you move the mouse).
View Replies
View Related
Apr 30, 2015
I'm working on making a game in JAVA. To be brief, the game is on a 6x6 matrix called "blocks[][]". The game has two players and the objective is to capture the enemies pieces by moving your piece onto there's. The players do this by moving one piece per turn either forward/backward (Vertically) or right/left (horizontal) movements. Essentially checkers without jumps.I'm not very far into the development process here. So far I have the game board created and the pieces load by clicking the "Start" button (handled by the refresh function). However I'm having a few problems... Namely moving the pieces effectively at the moment.
Right now there's a lot to do:
(1) - Implement a turn system,
(2) - Only allow a player to click their pieces (I've a validation function already in place to only permit valid moves [horizontal/vertical only]),
(3) - getting the pieces to actually "move" what I mean by this is a player selects the piece they want to move, then they select the spot they want to move to and the icon I have placed on the button is supposed to be added to the new square and the icon for its previous position is to be made null.
Please see the "actionPerformed" section to see exactly what I'm trying to do and hopefully as well see what I'm missing as to why it is not working at the moment... Also see under the Refresh function where I commented out the for loops to add the pieces. I did this because it was resulting in an ArrayOutofBounds error so I just wrote each spot out manually where I wanted them to start.
/* Ghosts *
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.border.*;
import java.io.*;
[code].....
View Replies
View Related
Aug 18, 2014
how I would go about having a moving sprite on a page, such as a virtual pet kind of thing. I've tried searching for it through the years and I've tried it with what I know on my own, but things just act up every time. Either:
A.) The sprite moves (respondent to key strokes, of course), but leaves a trail of its image behind itself.
B.) The background image writes, but for some reason the second image does not write, or is lost behind the background.
I'm sure these are simple issues for most of you, but I've tried going about this for a while now with no luck. What I'm trying to do I'm trying to write a virtual pet game, and I would eventually love to make it move around randomly like an A.I. that's pathfinding, but I've got ideas about that, just I need to know how to make it move period first, everything else I think I could figure out on my own.
View Replies
View Related
Sep 26, 2014
Listed below is the program I put together for class. I followed all of the instructions ....
import java.util.Scanner;
public class coinageJones{
int quarter = 0;
int dime = 0;
int nickel = 0;
int penny = 0;
int current = 0;
int original = 0;
int remainder1 = 0;
int remainder2 = 0;
int remainder3 = 0;
int remainder4 = 0;
[code]...
View Replies
View Related
Apr 13, 2014
I'm working on this space invaders game and I've been stuck trying to get the alien spaceships to move down in one group. The way we have to design the game is we have to implement at least these 3 classes. These classes are GameData,GamePanel, and Animator. GameData is all the action figures/models in the game. GamePanel draws all game action figures/ models on the screen. Animator updates periodicaly action figures positions,sizes, colors etc. I can get the aliens to move right but once they hit the end of the canvas I cannot figure out how to get them to move as a group down and then begin moving left. I tried to add alien objects to the GameFigures list and then have the update method in the Alien class be responsible for moving the alien ships, but I couldn't figure out how to make it work. So then I made an alienFigures list in the GameData class and I still cannot figure out what to do. Here is the GameData class
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
[code]....
View Replies
View Related
Mar 25, 2014
I've been creating a digital clock using Java, and have made the mouse cursor invisible after a set period of time (40-seconds) and had the thought to make it visible again if mouse was moved.
Here's the code that makes it invisible:
ActionListener mouseTimeout = new ActionListener() {
public void actionPerformed(ActionEvent e) {
setCursor(blankCursor);
}
};
/* Make mouse cursor disappear after 40 seconds */
Timer mTimeout = new Timer(40000, mouseTimeout);
mTimeout.start();
And here is what I have so far for making it visible again:
MouseMotionListener mouse = new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e)
{
}
@Override
public void mouseMoved(MouseEvent e)
{
}
};
I have tried using "setCursor(DEFAULT_CURSOR)" but NetBeans says that it "cannot find symbol" .....
View Replies
View Related
Feb 3, 2014
what is the coding for udp port scanning?
View Replies
View Related
Jul 25, 2014
is it possible to avoid deadlock while coding..
View Replies
View Related
Jun 9, 2014
public int getIndexOfAMonster(String nameToGet){
int retValue = -1; //default is not found
for (int i = 0; i <= numberOfMonsters - 1; i++)
if (monsters[i].getName().equals(nameToGet))
retValue = i;
return retValue;
}
1.What does the if-condition do?If the name of a monster in the array is equal to the name stored in the variable, return the monster's assigned value.
2.What does the for loop do? The loop condition simply loops through the whole arraylists. (In other words, it simply checks each Monster contained in the lists).
3.Assuming that the driver code compiles, explain what it’s use is? If the name of the monster is the same as the variable passed unto this method, return the number assigned to that Monster.
View Replies
View Related
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
Jan 26, 2015
I made a kind of maze game that includes the class keylistener and orients a object, i can't find where the program tracks this object (where its x and y coordinates are). So now my object can move freely through all walls and i want it to bounce back or at least something to happen when the object reaches a wall.
I want to find a way to limit my objects movement and because i cant find where the coordinates or variable for this object is i cannot limit its movement
View Replies
View Related
Feb 7, 2014
I'm doing project in area of "Cryptography and Network security". I'm having a file with binary Unicode (mean file contain Unicode value of corresponding data (text file)), want to divide that as blocks with the size of 144bits.
View Replies
View Related
Apr 22, 2015
What I am attempting to program is a simple Boss battle. I would like the user to have 2 options (for now): Run, or Attack. I got the portion completed and working, but once I tried to implement the Run feature (the way that it's supposed to work is you can either attack OR run), both Attack and Run will happen. Also, for some reason, the running always fails (it will always return the else statement, then move onto the attack.) Here's my code:
import java.util.*;
public class AdvancedBossBattle {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
Random gen = new Random();
int bosshp, bossdmg, playerhp, playerdmg, runChance;
String answer;
bosshp = 100;
[Code] ....
View Replies
View Related
Jan 8, 2015
I am required to create an electronic bandit machine that can display all images and buttons, user can input money, random display of images, machine stop when money runs out, user can put money in and start again and also a display of winnings. So far The user can input money and this is added to their bank however when the spin button is clicked no shapes appear despite their being a selection of images. My code is below.
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.*;
import javax.swing.Timer;
[code]....
View Replies
View Related
Aug 12, 2014
i want to make a circle with java coding.... i tried but i am grtting some error...
View Replies
View Related
Oct 25, 2014
I was required to make a program that contains 3 data fields, 2 constructors, and 4 methods. I'm having a hell of a time trying to put some input into this, where the user would choose from 1 of the 3 data fields I made up for car prices and choose their vehicle. As far as the constructors go, I made a default one but I'm not sure on how to A) implement another constructor and how do I involve the input into this and C) where the methods go in that.
I'm thinking of putting the input first but that ruins my constructors? I realize I asked a lot, but this is an online class without a text, and I'm basically starving for knowledge. [code]
public class Vehicle{
int truck;
int car;
int van;
[code]....
View Replies
View Related
Apr 1, 2015
When I compile the code, it goes through fine in the compiler. However after entering the boundaries for the lower an upper it doesn't produce the prime pairs between the two boundaries that the user sets. I have tried changing some of my integers that i initialized no luck. I looked at the last section of public void showPrimes() . However I can't seem to see where it has gone wrong there. I have included the entire code, plus the section again that I think is wrong. I have also posted the final output of what it looks like and what else should be included to make it easier to see what I am missing. Basically it keeps giving me zero primes even when the boundary is 100 and 200, or so and so forth.
import java.util.Scanner;
public class kbeaudry_xSieve
{
public static void main (String args[]){
kbeaudry_xSieve i = new kbeaudry_xSieve();
}
boolean primes[] = new boolean [50001];
int upper;
int lower;
[code]....
This is what i get when I actually run the program. However in the section where I have added *****, this is where it should put the prime pairs in.
Please enter a lower boundary and an upper boundary and I will print all of the sexy prime pairs between those boundaries.
Please enter the lower boundary (between 1 and 50000): 200
Please enter the upper boundary (between 1 and 50000): 600
There were 0 sexy pairs displayed between 200 and 600.. I am still working on another code for my that I had issues with, however I had to go out of the country for a few days to take care of some work.
View Replies
View Related
Mar 7, 2014
My OrderCalculator class is throwing an exception. The input from my HourPanel that is supposed to add to my OrderCalc is cooperating.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
public class OrderCalculator extends JFrame
{
private JobPanel jobs;
private HourPanel rate;
[Code] .....
View Replies
View Related
Sep 4, 2014
How to catch the event when table view's column are re-positioned. Basically when the column is re-positioned from 1 position to 5 position , i want to do update the db.
View Replies
View Related