Click here to Skip to main content
16,008,183 members
Home / Discussions / Work Issues
   

Work Issues

 
QuestionUDP broadcasting strange behaviour Pin
ppan27814-Oct-05 0:57
ppan27814-Oct-05 0:57 
AnswerRe: UDP broadcasting strange behaviour Pin
S Douglas30-Nov-05 21:43
professionalS Douglas30-Nov-05 21:43 
QuestionStarter KIT Problem Pin
Micu Radu11-Oct-05 2:03
Micu Radu11-Oct-05 2:03 
QuestionOffice Development BIG PROBLEM Pin
Micu Radu11-Oct-05 2:03
Micu Radu11-Oct-05 2:03 
QuestionLooking for a remote job. Pin
Alex Shapovalov10-Oct-05 23:49
professionalAlex Shapovalov10-Oct-05 23:49 
QuestionI need help Pin
cahmi9-Oct-05 22:48
cahmi9-Oct-05 22:48 
QuestionRe: I need help Pin
David Crow10-Oct-05 4:22
David Crow10-Oct-05 4:22 
QuestionMy First Java Game - For School WORK. Pin
PorkPants9-Oct-05 17:36
PorkPants9-Oct-05 17:36 
Hello this is my first java game and is very simple and easy. I have written the code below and was wondering if anyone would help me by making some suggestions on how I could clean up some inefficiences in the program or recode some of it to make it run smoother and more efficiently.

Any and all help is greatly appreciated and thanks in advance.
Here is the code (NB:The code is quite short so please take time to read it if you can help me)

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


public class Hunt extends Applet implements MouseListener{
Image background, bird;
int spike;
int birdyX, birdyY;
int x,y;
int score, darts;


public void init() {
darts = 10;
background = getImage(getCodeBase(), "graphics/background.gif");
bird = getImage(getCodeBase(), "graphics/bird.gif");
addMouseListener(this);

}
public void mouseClicked(MouseEvent e) {
x = e.getX();
y = e.getY();
darts = darts-1;
if (((x < birdyX+45) && (x > birdyX)) && ((y < birdyY+45) && (y > birdyY)))
score = score + 1;
repaint();
}

public void mouseReleased (MouseEvent e) {};
public void mouseEntered (MouseEvent e) {};
public void mouseExited (MouseEvent e) {};
public void mousePressed (MouseEvent e) {};


public void paint (Graphics g) {
g.drawImage(background,0,0, this);
spike = (int)(Math.random()*10);
switch (spike) {
case 0: {
g.drawImage(bird, 130, 250, 60, 45, this);
birdyX = 130;
birdyY = 250;
break;
}
case 1: {
g.drawImage(bird, 10, 25, 60, 45, this);
birdyX = 10;
birdyY = 25;
break;
}
case 2: {
g.drawImage(bird, 450, 275, 60, 45, this);
birdyX = 450;
birdyY = 275;
break;
}
case 3: {
g.drawImage(bird, 123, 450, 60, 45, this);
birdyX = 123;
birdyY = 450;
break;
}
case 4: {
g.drawImage(bird, 541, 310, 60, 45, this);
birdyX = 541;
birdyY = 310;
break;
}
case 5: {
g.drawImage(bird, 61, 345, 60, 45, this);
birdyX = 61;
birdyY = 345;
break;
}
case 6: {
g.drawImage(bird, 480, 360, 60, 45, this);
birdyX = 480;
birdyY = 360;
break;
}
case 7: {
g.drawImage(bird, 465, 329, 60, 45, this);
birdyX = 465;
birdyY = 329;
break;
}
case 8: {
g.drawImage(bird, 100, 200, 60, 45, this);
birdyX = 100;
birdyY = 200;
break;
}
case 9: {
g.drawImage(bird, 365, 220, 60, 45, this);
birdyX = 365;
birdyY = 220;
break;
}
}

if (darts == 0) {
g.setFont(new Font("Goudy Stoout", Font.BOLD, 14));
g.setColor(new Color(255,0,0));
g.drawString("Darts Remaining "+darts, 20, 20);
g.drawString("Your score is "+ score, 150, 20);
}
g.setFont(new Font("serif", Font.BOLD,14));
g.setColor(new Color(255,0,0));
g.drawString("Darts remaining "+darts, 20 ,20);
g.drawString("Your score is "+score,150, 20);


}
}
QuestionLooking for .net Contract Work Pin
keencomputer2-Oct-05 11:27
keencomputer2-Oct-05 11:27 
AnswerRe: Looking for .net Contract Work Pin
Paul Conrad21-Jul-06 12:44
professionalPaul Conrad21-Jul-06 12:44 
QuestionMCAD/MCSD Pin
Balaji Krishna1-Oct-05 2:46
Balaji Krishna1-Oct-05 2:46 
AnswerRe: MCAD/MCSD Pin
Colin Angus Mackay1-Oct-05 6:56
Colin Angus Mackay1-Oct-05 6:56 
GeneralRe: MCAD/MCSD Pin
Weiye Chen13-Oct-05 23:23
Weiye Chen13-Oct-05 23:23 
AnswerRe: MCAD/MCSD Pin
Dan Neely3-Oct-05 2:25
Dan Neely3-Oct-05 2:25 
AnswerRe: MCAD/MCSD Pin
vikas amin5-Oct-05 1:16
vikas amin5-Oct-05 1:16 
QuestionI am lookin for remote job ASP.NET Developer Pin
Alex Shapovalov28-Sep-05 23:05
professionalAlex Shapovalov28-Sep-05 23:05 
QuestionActiveSync Pin
Mvelo25-Sep-05 8:48
Mvelo25-Sep-05 8:48 
Question.NET Programmers Wanted (Java too) Pin
Quizboy24-Sep-05 8:25
Quizboy24-Sep-05 8:25 
JokeRe: .NET Programmers Wanted (Java too) Pin
toxcct25-Sep-05 0:26
toxcct25-Sep-05 0:26 
GeneralRe: .NET Programmers Wanted (Java too) Pin
Quizboy25-Sep-05 7:07
Quizboy25-Sep-05 7:07 
AnswerRe: .NET Programmers Wanted (Java too) Pin
Quizboy1-Oct-05 3:00
Quizboy1-Oct-05 3:00 
QuestionTwo observations Pin
ha_ha_ha23-Sep-05 1:46
ha_ha_ha23-Sep-05 1:46 
QuestionUpdated Control Library Pin
Kutlu Arasli23-Sep-05 1:16
Kutlu Arasli23-Sep-05 1:16 
QuestionOrion Network Performance Monitor Pin
Member 83853719-Sep-05 2:41
Member 83853719-Sep-05 2:41 
AnswerRe: Orion Network Performance Monitor Pin
S Douglas30-Nov-05 21:55
professionalS Douglas30-Nov-05 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.