Createing a game need help
ok im makeing a game i have made the map n photoshop just one big image
and i want it so java grabes the coords and print the type of tile that they are at
the map is pretty big
12500 X 14300
and i want to use that as the world map how would i grabe the pixiels from the map and use them as the ground the character will walk on
If you're lucky enough to be doing MIDP 2.0, it's provided for by the profile.
Otherwise, I imagine it's a matter of dividing the current user (x,y) location by the width and height of the tiles, thus getting an (x,y) position into the map. At that point it's just a matter of looking up the tiles from the map, and displaying them.
For example, suppose you have a character at position (23233,98483), and the window is 800x600 with the character at the center. And suppose the tiles are all 100x100 wide. Then you'd draw the tiles around (232,984) in your map.
Probably the easiest thing is to create a GameWorldMap object (I just made that name up to keep it from being confused with java.util.Map) that knows how to draw itself when handed a Graphics object and a position and a width and height. It would know how to translate map (world) coordinates into tile coordinates, and it would know how to offset the drawn tile images so the tiles could scroll smoothly off the edges of the screen.
Similar Messages
-
New to Java, want to create a game any help appreciated.
I just downloaded java Studio. I would like to create Java games. Not sure where to start.. Do i need more programs? Any info would be of great help thanks....
Hey,
If you want to know which software you need to program java games (or any other java application for that matter), I'm guessing you don't have much experience using java.
First, to answer your question, Studio will certainly do to create java. But even notepad will suffice. The only thing you really need to have is a SDK, you can get it from the Sun site.
Second, You should ask yourself if java is the language to program in. Java is well suited for developing games. But it is also a very powerful general purpose language, so it can be very overwhelming. Maybe you should think of the alternatives?
Flash: Has much better browser support than applets, so if you want to make an online game, this is probably a better choice. Don't be afraid of the possibilities in flash, unless you want to do 3d. You don't want do to 3d yet.
PHP: if your game is text based, you might want to program it in PHP. It is mostly used for multi-user-"dungeons"(fill that in as you want).
If you really want to learn how to program in java, I suggest you don't start on your game just yet. Try this PDF for starters: http://www.mindview.net/Books/TIJ/. The java tutorial is also pretty good, but cover the basics first: http://java.sun.com/docs/books/tutorial/ . I also suggest you don't start programming in an IDE(for you: Sun studio) until you start working with multiple classes. I suggest JEdit for "basic"(it has a million features, don't worry) programming. Later you can start to learn Sun Studio (Or Eclipse, if I can lodge in my preference), but be careful: these programs are excellent, and will spare you hours of work, but only if you spend (a lot) of time on how to use them properly.
As a final thought: the web is your friend. There are tons of good resources on the web for developing games, and lots of them focus on java. A good place for info is http://www.gamedev.net/, lots of articles, and helpful hints on choosing language, tile games, etc... Another specific one is http://www.brackeen.com/javagamebook/. It has working code for a tile-based game, and it even has a software 3d engine. It also has good for for detecting mouse and keyboard actions. Get more experience before you start with these ones, though.
Good luck! -
Hi all,
I need help with creating a "ragged" 2D array. The situation is that the columns have a static length which I know in advance but the number of rows needs to be defined per coloum seperatly. i know that i can create a ragged 2D array by setting the rows and looping throuh the rows setting the length (i.e. number of columns) but I have the opposite values. is this possible??Number of rows per column? A 2d array is basically
one column with M rows and each row is N items wide.
So define one collection object, I'll use a List for
the sake of argument. This is that one column with M
rows. For each row, add a List as an element in this
column, and add N elements to this row List. There
you go, a variable column length and each row is of a
variable length as well.The issue i have is when defining the 2d array i.e. lets say of type int
int[][] array = new int[M][N]
I do not know M but do know the value of N. only after I have defined this section I can then continue to define M for each N .. any ideas? -
Hi need help with cant buy game add on can buy from iTunes but not any game add on need help
To Contact iTunes Customer Service and request assistance
Use this Link > Apple Support iTunes Store Contact
Note:
Some In-App Purchases require a Credit Card. -
3d Games - need help just joined
Hello there, I have just joined this forum and am wondering where to start. I downloaded a 3d engine yesterday called 3DzzD although I didn't find it that useful. Could anyone point me in the right direction as to what I need to download etc so that I can make my own 3d game using the java script?
Much appreciated,
Mr.Clym
Ps: I have never used Java script before, Although I have used other different codes before, is there some tutorials that I could read to find out about scripting in java3d?
Message was edited by:
Mr.ClymOk, thx for your help but could you give me a link to
a java script forum? and a link to the game forum? as
I said I am very new to java
Message was edited by:
Mr.Clym
JavaScript forums:
http://www.google.com/search?hl=en&q=javascript+forum&btnG=Google+Search
Java game-section of this forum:
http://forum.java.sun.com/forum.jspa?forumID=406
Difference between Java and JavaScript:
http://www.developer.com/java/other/article.php/639301 -
Help Needed For Creating A Game
Hi, I recently decided to make a MMORPG.A game people will enjoy and have fun, I would of course keep it free sense I have play many games that cost 5-15 dollars a month.I have many creative ideas, but I need someone to show me the ropes and teach me how to use Java and i currently looking for a site to download it at.If anyone would care to teach me how to use this or would like to help me create this game(Medievil type game, Swords armor gold houses dragonslaying and plenty more) post here or send me a pm and we can talk more private.
I need:
*A site to download the best possiable Java console
*Helpful tutorial sites
*Or any other sites or tips you think i should know.
Extra Info On Me:
I dont know if this matters or not probably doesnt but I know how to handle and make a site, ive had some dbz rpgs back in the day(kinda rusty but i can manage).
Some more recent information:
I tried game maker and that doesnt seem to helpful.It would only be helpful if I played them 20 bucks which I am not going to do.
Also i am downloading now JS2E 5.0 for Java.
I am stilling waiting on some type of input or even a mentor.Hi there!
I'm not really a game programmer.. but here's some links anyway.
Someone pointed out this tutorial to me, and I think it is worthwhile:
http://fivedots.coe.psu.ac.th/~ad/jg/
It has stuff on Java 3D, networking, games for mobile phones/PDAs, isometric tile games, etc. It also has an appendix on loaders and Java Web Start.
Also, if you want to create 3D games, you might want to check out
http://www.3dcafe.com/asp/freestuff.asp
They have free 3D models in various formats.
For more 3D links and tutorials try:
http://www.3dlinks.com/
For a 3D tool, I like Anim8or. That it's free helps a lot ;)
http://www.anim8or.com/
And... ms paint!?! You will not be able to draw decent graphics with that. Adobe Photoshop Elements is a nice, low-cost program for 2D images.
There are lots of sites devoted to java game programming. Try the google. Love the google. Google is your friend. ;)
:) jen -
Creating breakout game. Need help with thread starting.
Howdy. As the title says, I've got an assignment to make a breakout game. So far it's going alright, but I've run into a rather large snag...I can't get it to animate :P I've got my main applet, then I created a class heirarchy for the paddle, ball, and brick objects. For this question, lets just focus on the ball object.
This is my applet code so far (it is not even close to being done, so don't laugh :P )
import java.awt.*;
import javax.swing.*;
import java.util.*;
* Class BreakoutApplet - Plays a simple game of Breakout.
* @author Kris Nelson
* @version November 10, 2004
public class BreakoutApplet extends JApplet implements Runnable
protected Brick brick; // creates an object of class brick
protected Ball ball; // creates an object of class ball
protected Paddle paddle; // creates an object of class paddle
protected boolean running; // tells the program whether or not the thread is running
protected ArrayList brickArray = new ArrayList(); // stores all the bricks in the game
protected Thread timer; // the thread which controls the animation for the applet
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
public void init()
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
createBricks(); // creates the games array of bricks
ball = new Ball(400, 400, 2, 2); // sets the values for the ball
paddle = new Paddle(300, 660, 2); // sets the values for the paddle
// !!!!!!! have tried placing ball.start() here
* Paint method for applet.
* @param g the Graphics object for this applet
public void paint(Graphics g)
// draws the background, border, and all the games objects
g.setColor(Color.lightGray); // sets the drawing color to light gray
g.fillRect(0, 0, 600, 700); // displays the game screens background
displayBorder(g); // displays the game screens border
displayBricks(g); // displays the array of bricks
ball.display(g); // displays the ball
paddle.display(g); // displays the paddle
* Creates the games array of bricks
public void createBricks()
int colorNumber = 1; // starts the color of the bricks at orange
double yPosition = 100; // starts the bricks y screen position at 100
for(int i = 0; i < 4; i++)
double xPosition = 12; // starts the bricks x screen position at 12
for(int j = 0; j < 8; j++)
if(colorNumber == 0)
colorNumber = 1; // sets the color of the bricks to orange
else
colorNumber = 0; // sets the color of the bricks to green
brickArray.add(brick = new Brick(xPosition, yPosition, colorNumber)); // adds a brick to the current container in the brick array
xPosition = xPosition + brick.getWidth(); // move the bricks x screen position to the next column
yPosition = yPosition + brick.getHeight(); // moves the bricks y screen position to the next row
if(colorNumber == 0)
colorNumber = 1; // sets the color of the bricks to orange
else
colorNumber = 0; // sets the color of the bricks to green
* Displays the game screens border
* @param g the Graphics object for this applet
public void displayBorder(Graphics g)
g.setColor(Color.black); // sets the drawing color to black
g.fillRect(0, 0, 600, 24); // draws a border on the top of the screen
g.fillRect(0, 0, 12, 700); // draws a border on the left of the screen
g.fillRect(588, 0, 12, 700); // draws a border on the right of the screen
* Displays the array of bricks on the screen
* @param g the Graphics object for this applet
public void displayBricks(Graphics g)
Brick currentBrick; // holds the brick data from the current ArrayList container
for(int i = 0; i < 32; i++)
currentBrick = (Brick)(brickArray.get(i)); // grabs the brick data from the current ArrayList container
currentBrick.display(g); // displays the current brick
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
public void start()
if(timer == null)
timer = new Thread(this); // creates a new object of type Thread
timer.start(); // starts the new thread
running = true; // tells the program that the new thread is running
* Runs the code that controls the animation
public void run()
do{
repaint(); // redraws the screen
try{
timer.sleep(100); // puts the thread to sleep for 100 milliseconds
} catch(InterruptedException e) {running = false;}
// !!!!!!! have tried placing ball.start() here
} while(running);
timer = null; // destroys the timer thread
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
public void stop()
running = false; // tells the program that the thread is now done
}These are the bits of code for my class heirarchy, just to (hopefully) make it easier to follow.
import java.awt.*;
* The parent class of all the games objects.
* @author Kris Nelson
* @version November 9, 2004
public class Sprite
protected double screenX, screenY; // stores the x and y location of the object
* Constructor for objects of class Sprite
* @param xPosition the initial x screen position
* @param yPosition the initial y screen position
public Sprite(double xPosition, double yPosition)
screenX = xPosition; // sets the initial x screen position
screenY = yPosition; // sets the initial y screen position
* Sets new x and y screen locations for an object
* @param newX the new x screen location
* @param newY the new y screen location
public void setScreenXY(double newX, double newY)
screenX = newX; // sets the new x screen location
screenY = newY; // sets the new y screen location
* Sends back the current x screen location
* @return the current x screen location
public double getScreenX()
return screenX; // returns the current x screen location
* Sends back the current y screen location
* @return the current y screen location
public double getScreenY()
return screenY; // returns the current y screen location
import java.awt.*;
* Parent class of any game object that moves.
* @author Kris Nelson
* @version November 9, 2004
public class MovingSprite extends Sprite implements Runnable
protected double speedX, speedY; // stores the speed of an object in the x and y directions
protected Thread timer; // the thread which controls animation for all moving objects
protected boolean running; // tells the program whether or not the thread is running
* Constructor for objects of class MovingSprite
* @param xPosition the initial x screen position
* @param yPosition the initial y screen position
* @param xSpeedValue the speed in the x direction
* @param ySpeedValue the speed in the y direction
public MovingSprite(double xPosition, double yPosition, double xSpeedValue, double ySpeedValue)
super(xPosition, yPosition); // passes the initial screen positions to Sprite
speedX = xSpeedValue; // sets the speed in the x direction
speedY = ySpeedValue; // sets the speed in the y direction
* Sends back the speed in the x direction
* @return the speed in the x direction
public double getSpeedX()
return speedX; // returns the speed in the x direction
* Sends back the speed in the y direction
* @return the speed in the y direction
public double getSpeedY()
return speedY; // returns the speed in the y direction
* Starts the thread in order to start animation
public void start()
if(timer == null)
timer = new Thread(this); // creates a new object of type Thread
timer.start(); // starts the new thread
running = true; // tells the program that the new thread is running
* Empty since the child objects have their own run methods
public void run()
* Stops the thread from running
public void stop()
running = false; // tells the program that the thread is now done
import java.awt.*;
* Creates a single ball who's purpose is to bounce around and destroy the bricks.
* @author Kris Nelson
* @version November 10, 2004
public class Ball extends MovingSprite
protected static final double BALL_WIDTH = 15; // sets the width of the ball
protected static final double BALL_HEIGHT = 15; // sets the height of the ball
* Constructor for objects of class Ball
* @param xPosition the initial x screen position
* @param yPosition the initial y screen position
* @param xSpeedValue the speed in the x direction
* @param ySpeedValue the speed in the y direction
public Ball(double xPosition, double yPosition, double xSpeedValue, double ySpeedValue)
super(xPosition, yPosition, xSpeedValue, ySpeedValue); // passes the initial screen positions and ball speeds to MovingSprite
// !!!!!!!! have tried placing timer.start() here
* Displays a ball onto the screen
* @param g the Graphics object for this applet
public void display(Graphics g)
g.setColor(Color.blue); // sets the balls color
g.fillOval((int)(screenX), (int)(screenY), (int)(BALL_WIDTH), (int)(BALL_HEIGHT)); // displays the ball
* Runs the code that controls the balls animation
public void run()
do{
try{
timer.sleep(100); // puts the thread to sleep for 100 milliseconds
} catch(InterruptedException e) {running = false;}
screenX = screenX + speedX;
screenY = screenY + speedY; // this is VERY SIMPLE BALL MOVEMENT FOR TESTING PURPOSES, WILL BE CHANGED LATER
} while(running);
}Sorry if that was too much code. I'm just trying to make this easier to follow.
I placed a // !!!!!!!!!!!!! comment in the places where I have tried starting the ball thread.
So basically, everything is running fine, except that I'm not at all sure of where to start the ball Thread, and thus can't start anything moving. If someone could tell me where I should be starting the thread, I would REALLY appriciate it. Thank you :D
- KrisSome advice.
1. the start method on the ball should be called from the start method on the applet and should in turn call the start method on the sprite's thread.
2. the run method of the Moveable sprite should have been declare abstract
3. don't implement borders manually. There's a java.awt.Border class for that.
4. probably, you don't want to have the game invoke each sprite by name; just make a big list of all the sprites and invoke all of them every time
5. do you really need provision for a non-circular ball? this isn't rugby.
6. I don't think you ever had a threading problem, just a display problem.
7. Don't write comments like this: ball.display(g); // displays the ballHere's my (even more simplified version):import java.awt.*;
import javax.swing.*;
import java.util.*;
* Class BreakoutApplet - Plays a simple game of Breakout.
* @author Kris Nelson, modified by Michael Lorton
* @version November 10, 2004
public class BreakoutApplet extends JApplet implements Runnable {
protected Ball ball;
protected Paddle paddle;
public boolean running; // tells the program whether or not the thread is running
protected Thread timer; // the thread which controls the animation for the applet
public void init() {
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
getRootPane().putClientProperty("defeatSystemEventQueueCheck",
Boolean.TRUE);
ball = new Ball(this, GAMEWIDTH / 2, GAMEHEIGHT / 2, 5, 5);
public final static int GAMEWIDTH = 600;
public final static int GAMEHEIGHT = 400;
public void paint(Graphics g) {
g.setColor(Color.lightGray);
g.fillRect(0, 0,
GAMEWIDTH, GAMEHEIGHT);
ball.display(g); // displays the ball
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
public void start() {
if(timer == null) {
timer = new Thread(this); // creates a new object of type Thread
timer.start(); // starts the new thread
running = true; // tells the program that the new thread is running
ball.start();
* Runs the code that controls the animation
public void run() {
do{
repaint(); // redraws the screen
try{
Thread.sleep(100);
} catch(InterruptedException e) {running = false;}
} while(running);
public void stop() {
running = false;
abstract class Sprite {
protected double screenX, screenY; // stores the x and y location of the object
protected final BreakoutApplet parent;
* Constructor for objects of class Sprite
* @param xPosition the initial x screen position
* @param yPosition the initial y screen position
public Sprite(BreakoutApplet parent, double xPosition, double yPosition) {
this.parent = parent;
screenX = xPosition; // sets the initial x screen position
screenY = yPosition; // sets the initial y screen position
* Sets new x and y screen locations for an object
* @param newX the new x screen location
* @param newY the new y screen location
public void setScreenXY(double newX, double newY) {
screenX = newX; // sets the new x screen location
screenY = newY; // sets the new y screen location
* Sends back the current x screen location
* @return the current x screen location
public double getScreenX() {
return screenX; // returns the current x screen location
* Sends back the current y screen location
* @return the current y screen location
public double getScreenY() {
return screenY; // returns the current y screen location
abstract public void display(Graphics g);
* Parent class of any game object that moves.
* @author Kris Nelson
* @version November 9, 2004
abstract class MovingSprite extends Sprite implements Runnable {
protected double speedX, speedY; // stores the speed of an object in the x and y directions
protected Thread timer; // the thread which controls animation for all moving objects
protected boolean running; // tells the program whether or not the thread is running
* Constructor for objects of class MovingSprite
* @param xPosition the initial x screen position
* @param yPosition the initial y screen position
* @param xSpeedValue the speed in the x direction
* @param ySpeedValue the speed in the y direction
public MovingSprite(BreakoutApplet parent,
double xPosition, double yPosition,
double xSpeedValue, double ySpeedValue) {
super(parent, xPosition, yPosition);
speedX = xSpeedValue; // sets the speed in the x direction
speedY = ySpeedValue; // sets the speed in the y direction
* Starts the thread in order to start animation
public void start() {
if(timer == null) {
timer = new Thread(this); // creates a new object of type Thread
timer.start(); // starts the new thread
running = true; // tells the program that the new thread is running
* Runs the code that controls the balls animation
public void run() {
while (parent.running) {
try{
Thread.sleep(100);
} catch(InterruptedException e) {
System.err.println(e);
step();
abstract protected void step();
* Creates a single ball whose purpose is to bounce around and destroy the bricks.
* @author Kris Nelson
* @version November 10, 2004
class Ball extends MovingSprite {
protected static final int BALL_DIAMETER = 15;
* Constructor for objects of class Ball
* @param xPosition the initial x screen position
* @param yPosition the initial y screen position
* @param xSpeedValue the speed in the x direction
* @param ySpeedValue the speed in the y direction
public Ball(BreakoutApplet parent,
double xPosition, double yPosition,
double xSpeedValue, double ySpeedValue) {
super(parent, xPosition, yPosition, xSpeedValue, ySpeedValue);
* Displays a ball onto the screen
* @param g the Graphics object for this applet
public void display(Graphics g) {
g.setColor(Color.blue);
g.fillOval((int)(screenX),
(int)(screenY),
BALL_DIAMETER, BALL_DIAMETER);
protected void step() {
screenX = screenX + speedX;
if (screenX < 0) {
screenX = -screenX;
speedX = -speedX;
else if ((screenX + BALL_DIAMETER)> BreakoutApplet.GAMEWIDTH) {
screenX = 2*(BreakoutApplet.GAMEWIDTH - BALL_DIAMETER) - screenX;
speedX = -speedX;
screenY = screenY + speedY;
if (screenY < 0) {
screenY = -screenY;
speedY = -speedY;
else if ((screenY + BALL_DIAMETER) > BreakoutApplet.GAMEHEIGHT) {
screenY = 2*(BreakoutApplet.GAMEHEIGHT - BALL_DIAMETER) - screenY;
speedY = -speedY;
} -
I need help with shooting in my flash game for University
Hi there
Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
listed below should be the correct code
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
listed below is my entire code
import flash.display.MovieClip;
//declare varibles to create mines
//how much time before allowed to shoot again
var cTime:int = 0;
//the time it has to reach in order to be allowed to shoot (in frames)
var cLimit:int = 12;
//whether or not the user is allowed to shoot
var shootAllow:Boolean = true;
var minesInGame:uint;
var mineMaker:Timer;
var cursor:MovieClip;
var index:int=0;
var tankMine_mc:MovieClip;
var antiTankmine_mc:MovieClip;
var maxHP:int = 100;
var currentHP:int = maxHP;
var percentHP:Number = currentHP / maxHP;
function initialiseMine():void
minesInGame = 15;
//create a timer fires every second
mineMaker = new Timer(6000, minesInGame);
//tell timer to listen for Timer event
mineMaker.addEventListener(TimerEvent.TIMER, createMine);
//start the timer
mineMaker.start();
function createMine(event:TimerEvent):void
//var tankMine_mc:MovieClip;
//create a new instance of tankMine
tankMine_mc = new Mine();
//set the x and y axis
tankMine_mc.y = 513;
tankMine_mc.x = 1080;
// adds mines to stage
addChild(tankMine_mc);
tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal(evt:Event):void{
evt.target.x -= Math.random()*5;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseMine();
//declare varibles to create mines
var atmInGame:uint;
var atmMaker:Timer;
function initialiseAtm():void
atmInGame = 15;
//create a timer fires every second
atmMaker = new Timer(8000, minesInGame);
//tell timer to listen for Timer event
atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
//start the timer
atmMaker.start();
function createAtm(event:TimerEvent):void
//var antiTankmine_mc
//create a new instance of tankMine
antiTankmine_mc = new Atm();
//set the x and y axis
antiTankmine_mc.y = 473;
antiTankmine_mc.x = 1080;
// adds mines to stage
addChild(antiTankmine_mc);
antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal_2(evt:Event):void{
evt.target.x -= Math.random()*10;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseAtm();
function moveForward():void{
bg_mc.x -=10;
function moveBackward():void{
bg_mc.x +=10;
var tank_mc:Tank;
// create a new Tank and put it into the variable
// tank_mc
tank_mc= new Tank;
// set the location ( x and y) of tank_mc
tank_mc.x=0;
tank_mc.y=375;
// show the tank_mc on the stage.
addChild(tank_mc);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
//creates the movement
function onMovementKeys(evt:KeyboardEvent):void
//makes the tank move by 10 pixels right
if (evt.keyCode==Keyboard.D)
tank_mc.x+=5;
//makes the tank move by 10 pixels left
if (evt.keyCode==Keyboard.A)
tank_mc.x-=5
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
if (tank_mc.hitTestObject(antiTankmine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(antiTankmine_mc);
if (tank_mc.hitTestObject(tankMine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(tankMine_mc);
//var maxHP:int = 100;
//var currentHP:int = maxHP;
//var percentHP:Number = currentHP / maxHP;
//Incrementing the cTime
//checking if cTime has reached the limit yet
if(cTime < cLimit){
cTime ++;
} else {
//if it has, then allow the user to shoot
shootAllow = true;
//and reset cTime
cTime = 0;
function updateHealthBar():void
percentHP = currentHP / maxHP;
healthBar.barColor.scaleX = percentHP;
if(currentHP <= 0)
currentHP = 0;
trace("Game Over");
updateHealthBar();USe the trace function to analyze what happens and what fails to happen in the code you showed. trace the conditional values to see if they are set up to allow a shot when you press the key
-
Need help with animation, for my XAML game
Hello friends,
I need help in creating animation for my snake and ladder game(C#,XAML). I have completed the game logic, but can't understand how to animate my UI.
1. I want to animate 6 dice images so that when the player clicks on the Roll Dice Button a shuffle animation will play, and while the animation is playing the user can't click any thing.
2. I want the player disc to move one step at a time (animation) on the game board.
Please help me I am new to animation. Kindly give a replyHello,
I would recommend using
Storyboards and / or the
XAML animation library.
Other resources:
Storyboarded animations (XAML)
XAML animation library sample
I hope this helps,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/ -
Need help for my "pairs" game! Do Help me!
Hi
Will somebody help me about my midterm project? I am about to make a static game called pairs...Now the first thing i need to know is "how to create a two dimensional array of JButtons?" I already know how to make some GUI components like menus, radio buttons..etc. I also got my images ready..another problem is how to use math random to randomly assign the images to the buttons. I really need help and I'm new here. Will somebody show me a very very simple code of this game. pls do help. Im 17 yrs old and new in programming.
my email: [email protected]
All help is appreciated.Don't cross-post.
No, we won't do your homework for you.
Nobody cares how old you are or how new you are to programming.
When is this due?
% -
I need to create Buttons dynamically Please Help
I am currently developing a card game. I represent my cards as buttons. But as the player draws more cards from the deck I have to generate buttons dynamically at run-time. I could use arrays of buttons and store new buttons inside that arrays of buttons. But the only problem is I need ActionListener for each of my buttons. How do you create ActionListener for each different dynamically created buttons? Please Help.
Here is my code. I just do not understand how to create those functions dynamically that functions different each time.
Here is my code please take a look.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class run108{
JButton setbutton;
JButton ButtonUp;
JButton ButtonDeal;
JButton slot1;
JButton slot2;
JButton slot3;
JButton slot4;
JButton slot5;
JButton slot6;
JButton slot7;
cards[] card = new cards[55];
public static void main(String[] argv)
run108 startgui = new run108();
startgui.createframe();
void createframe()
//Standard of way of creating Frame
JFrame frame = new JFrame("108");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(300,200);// Tells the startup position;
//Adding Panels to the framework
JPanel panelA = new JPanel();
panelA.setBackground(Color.white);
panelA.setLayout(new BoxLayout(panelA,BoxLayout.Y_AXIS));
JPanel panelB = new JPanel();
JPanel panelC = new JPanel();
//Adding buttons with card images
JLabel label1 = new JLabel(" Set of Cards");
panelA.add(label1);
ImageIcon pic1 = new ImageIcon("cards/backd.png");
setbutton = new JButton(pic1);
panelA.add(setbutton);
ImageIcon picdeal = new ImageIcon("cards/deal.png");
ButtonDeal = new JButton(picdeal);
panelA.add(BorderLayout.CENTER, ButtonDeal);
ButtonDeal.addActionListener(new DealListener());
JLabel label2 = new JLabel(" Your Target");
panelA.add(label2);
ButtonUp = new JButton(pic1);
panelA.add(BorderLayout.CENTER, ButtonUp);
frame.add(BorderLayout.WEST,panelA);
// Adds 7 initial card slots.
ImageIcon pic2 = new ImageIcon("cards/backc.png");
slot1 = new JButton(pic2);
panelB.add(slot1);
slot1.addActionListener(new Slot1Listener());
slot2 = new JButton(pic2);
panelB.add(slot2);
slot2.addActionListener(new Slot2Listener());
slot3 = new JButton(pic2);
panelB.add(slot3);
slot3.addActionListener(new Slot3Listener());
slot4 = new JButton(pic2);
panelB.add(slot4);
slot4.addActionListener(new Slot4Listener());
slot5 = new JButton(pic2);
panelB.add(slot5);
slot5.addActionListener(new Slot5Listener());
slot6 = new JButton(pic2);
panelB.add(slot6);
slot6.addActionListener(new Slot6Listener());
slot7 = new JButton(pic2);
panelB.add(slot7);
slot7.addActionListener(new Slot7Listener());
frame.add(BorderLayout.CENTER,panelB);
// This has to be added @ the end to show the components
//that were added after on. If it is placed before the components
//the components shall not appear since they sit on the frame
frame.setSize(600,500);
frame.setVisible(true);
class DealListener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot1Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot2Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot3Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot4Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot5Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot6Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
class Slot7Listener implements ActionListener
public void actionPerformed(ActionEvent event){}
} -
Trying to create a Invoice based on Order need help Error -5002
the dreaded -5002 error is haunting me too! and I could not find a matching solution for this in the forum....
I need help quickly on this. I am trying to create invoices for some orders so the Base - Target relationship is retained. The orders I pick are all Open (DocStatus = O and the lines are all Open LineStatus = O)
here is my code
oInvoice.Lines.BaseEntry = 48
oInvoice.Lines.BaseLine = 0
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
oInvoice.Lines.ItemCode = "A00001"
oInvoice.Lines.ItemDescription = "IBM Infoprint 1312"
'adding Line
oInvoice.Lines.Add
oInvoice.Lines.BaseEntry = 48
oInvoice.Lines.BaseLine = 1
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
oInvoice.Lines.ItemCode = "A00002"
oInvoice.Lines.ItemDescription = "IBM Inforprint 1222"
'adding Line
oInvoice.Lines.Add
lRetCode = oInvoice.Add
If lRetCode <> 0 Then
gObjCompany.GetLastError lErrCode, sErrMsg
MsgBox (lErrCode & " " & sErrMsg)
End IfIndika,
Only set your base types...
(not items & description)
oInvoice.Lines.BaseEntry = 48
oInvoice.Lines.BaseLine = 0
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
oInvoice.Lines.ItemCode = "A00001"
oInvoice.Lines.ItemDescription = "IBM Infoprint 1312"
'adding Line (to fill the second item line)
' the 1st line item is there by default
oInvoice.Lines.Add
oInvoice.Lines.BaseEntry = 48
oInvoice.Lines.BaseLine = 1
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
oInvoice.Lines.ItemCode = "A00002"
oInvoice.Lines.ItemDescription = "IBM Inforprint 1222"
'DO NOT Add THIS line
' (only if you want to add a 3rd line item)
'''oInvoice.Lines.Add -> Don't add this
lRetCode = oInvoice.Add
If lRetCode <> 0 Then
gObjCompany.GetLastError lErrCode, sErrMsg
MsgBox (lErrCode & " " & sErrMsg)
End If
remember to add :
oInvoice.CardCode = "your BP"
oInvoice.DocDueDate = Now
oInvoiceDoc.CardCode = txtDOCBPCode.Text -
If i reset my ipad can i install paye games for free if i sign back into my apple ID. Please i need help because i need to update my games but i need to put in this billing thing and i want to get rid of it so then i cant buy games with my credit card
Hello,
As frustrating as it seems, your best to post any frustrations about the iPhone in the iPhone discussion here:
https://discussions.apple.com/community/iphone/using_iphone
As this discussion is for iBook laptops.
Best of Luck. -
Need Help to create new screen for RF Sapconsole
Hi Guru's
I'm new on RF (but some years in ABAP) since last week.
I need help to create new screens for RF (SAPLLMOB).
Can someone explain me the procedure to create screen (with ABAP code after) or perhaps someone have an exemple (simple or not) ?
I have to develop 2 new screens with really few time.
And, another subsidiary question :
how SAP can transfert information between the flash gun and the screen i have developped.
Is there some code to add to enable this functionality or it is include in SAPLLMOB on standard fields ????
It's a new strange world for me today...
Many thanks to everyone who can explain me
Alainhi,
I am facing this problem as well. Is there any reference to create the new screen?
Hope someone can help! Thanks!
Regards,
Darren -
Need help in creating a chart from 3 datasets
Need help in creating a chart in SSRS from 3 datasets
Can someone help me in creating a chart from 3 datasets, however datasource is same.Thank you Olaf...
could anyone help me in using union all with the below
WITH a AS (
SELECT
clientid,
DATEPART(year, row_date) AS 'Year',
DATEPART(month, row_date) AS 'Month',
value ,
CASE metricid WHEN 16 THEN 'FCR' ELSE 'Cases' END AS metric
FROM XXXXXX AS V
WHERE metricid IN (16, 11)
AND row_date BETWEEN '2012-01-01' AND '2014-10-01'
AND value IS NOT NULL)
, b AS (
SELECT clientid ,
Year ,
Month ,
value AS 'Cases',
metric
FROM a
WHERE metric = 'cases')
, c AS (
SELECT clientid ,
Year ,
Month ,
value AS 'FCR',
metric
FROM a
WHERE metric = 'FCR')
, d AS (
SELECT b.YEAR, b.MONTH, c.FCR, b.Cases
FROM b INNER JOIN c
ON c.clientid = b.clientid
AND c.[YEAR] = b.[year]
AND c.[month] = b.[month]
WHERE c.fcr <> 0 AND b.cases <> 0
,E AS (
SELECT [Year], [Month], SUM(FCR) AS FCR, SUM(Cases) AS Cases
FROM d
GROUP BY [Year], [Month])
select YEAR, MONTH,
CASE MONTH
WHEN 1 THEN 'Jan'
WHEN 2 THEN 'Feb'
WHEN 3 THEN 'Mar'
WHEN 4 THEN 'Apr'
WHEN 5 THEN 'May'
WHEN 6 THEN 'Jun'
WHEN 7 THEN 'Jul'
WHEN 8 THEN 'Aug'
WHEN 9 THEN 'Sep'
WHEN 10 THEN 'Oct'
WHEN 11 THEN 'Nov'
WHEN 12 THEN 'Dec'
END AS MonthName
,e.FCR AS FCRCases
,e.Cases AS TotalCases
,CASE
WHEN [month] IN (11, 12, 1) THEN 1
WHEN [month] IN (2, 3, 4) THEN 2
WHEN [month] IN (5, 6, 7) THEN 3
WHEN [month] IN (8, 9, 10) THEN 4
END AS 'Quarter'
--,CONVERT(DECIMAL(18, 2),(e.FCR/e.Cases)*100) AS FCRRaw
from e
order by YEAR, MONTH
**************2nd query*************
WITH a AS (
SELECT
clientid,
DATEPART(year, row_date) AS 'Year',
DATEPART(month, row_date) AS 'Month',
value,
CASE metricid WHEN 56 THEN 'numerator' ELSE 'denominator' END AS metric
FROM XXXXXXX.[Values] AS V
WHERE metricid IN (56, 10)
--WHERE metricid IN (11,16)
AND row_date BETWEEN '2013-10-01' AND '2014-02-01'
AND value IS NOT NULL)
, b AS (
SELECT clientid ,
Year ,
Month ,
value AS 'numerator',
metric
FROM a
WHERE metric = 'numerator')
, c AS (
SELECT clientid ,
Year ,
Month ,
value AS 'denominator',
metric
FROM a
WHERE metric = 'denominator')
, d AS (
SELECT b.YEAR, b.MONTH, c.denominator, b.numerator
FROM b INNER JOIN c
ON c.clientid = b.clientid
AND c.[YEAR] = b.[year]
AND c.[month] = b.[month]
WHERE c.denominator <> 0 AND b.numerator <> 0
, e AS (
SELECT [Year], [Month], SUM(numerator) AS numerator, SUM(denominator) AS denominator
FROM d
GROUP BY [Year], [Month]
SELECT *,
CASE
WHEN [month] IN (11, 12, 1) THEN 1
WHEN [month] IN (2, 3, 4) THEN 2
WHEN [month] IN (5, 6, 7) THEN 3
WHEN [month] IN (8, 9, 10) THEN 4
END AS 'Quarter'
FROM e
ORDER BY 1,2
******************3rd query**************
WITH a AS (
SELECT --L.[LocationGroupId],
-- T.locationid,
-- T.AccountId,
TR.datestamp,
/*Convert(NVARCHAR, DatePArt(year, TR.datestamp)) + '-' + Convert(NVARCHAR, DatePArt(month, TR.datestamp)) + '-01'*/
TR.Period AS ValueDate,
CASE WHEN TR.TargetResultState = 0 THEN 0 WHEN TR.TargetResultState = 1 THEN 1 WHEN TR.TargetResultState = 2 THEN 1 ELSE 0 END AS Met,
CASE WHEN CONVERT(DATE, Convert(NVARCHAR, DatePArt(year, TR.datestamp)) + '-' + Convert(NVARCHAR, DatePArt(month, TR.datestamp)) + '-01') > T.Startdate AND CONVERT(DATE, Convert(NVARCHAR, DatePArt(year, TR.datestamp))
+ '-' + Convert(NVARCHAR, DatePArt(month, TR.datestamp)) + '-01') < T.Enddate THEN 1 ELSE 0 END AS ActiveTarget
FROM XXXXXX AS TR
INNER JOIN dbo.Target T ON TR.TargetID = T.ID
--INNER JOIN dbo.Location L ON T.Locationid = L.Id
WHERE --locationid <> - 1 AND
TR.Period IN ('201306', '201307', '201308', '201309', '201310', '201311', '201312', '201401'))
select ValueDate, SUM(Met) AS Met, Count(ActiveTarget) AS ActiveTargets,
right(ValueDate,2) as Month
,left(ValueDate,4) as Year
,CASE
WHEN right(ValueDate,2) IN (11, 12, 1) THEN 1
WHEN right(ValueDate,2) IN (2, 3, 4) THEN 2
WHEN right(ValueDate,2) IN (5, 6, 7) THEN 3
WHEN right(ValueDate,2) IN (8, 9, 10) THEN 4
END AS 'Quarter'
from a
group by ValueDate
order by ValueDate
Maybe you are looking for
-
How to install jsdk on Red Hat Linux 9.0
Im new user of Linux using RedHat Linux9.0 with kernel-2.4.20-8 with /lib/libc-2.3.2.so .... Ive downloaded both: j2sdk-1_3_1_08-linux-i586.bin and j2sdk-1_3_1_08-linux-i586.rpm.bin and execute the following commands but there was no results not even
-
Activate Cost Component Split in Controlling Area Currency
Hello, I have controlling area currency USD and company code currency INR. When I do WIP run then system is giving error messages "contr.area currecy is missing" and "not find valid cost component structure" and suggesting to maintain "Cost Component
-
Payables - Adjustments to paid invoices
Hello, We've disabled the Option "Allow adjustments to paid invoices" in Payables Options, in order to improve controls. We activated a DFF at invoice header level. Now the user cannot change any filds of a paid invoice. However we would like to let
-
Using Numbers to shedule sort problem
I am using Numbers to schedule the times that groups perform at an event I am organizing. If I make a time change to a group Numbers has also tagged this with the date of my entry and this affects the sorting. Is there a way to turn this off? I have
-
Working on DVDSP 4.1.2, Mac OS 10.5.4, on a MacBook Pro 2.4, 4 gigs ram, I have been building a Main Menu. There are about a dozen buttons that have motion in them from the video track they are linked too. I wanted on State 1/Normal of the button to