Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Games Center / Archived Projects / Re: A dozen stupid games! on: 2008-06-05 21:05:32
I was really bored...


2  Java Game APIs & Engines / Java 3D / Looking for good 3d/jogl applet tutorial on: 2007-12-20 19:02:23
i have programmed java few months now i want to test 3d programming and i need good tutorial...
3  Game Development / Newbie & Debugging Questions / Re: Little problem on: 2007-11-19 18:11:32
Short introduction to the Finnish language:

sydan (sydän) = heart
aika = time
aks (akseli?) = axis
pisteet = points
livet (English word "live/life" in Finnish plural, the real Finnish word is "elämät") = lives
oikee (slang for "oikea") = right
vasen = left
tippuu = [it] falls
alas = down

PS: It's better to write all code in English. Then more people can read the code and the code will look more consistent, because every library you will use is also written in English. And even though Java supports Unicode characters in variable and method names, that does not mean that you should use them there. (I once tried writing method names with Chinese characters just to see that it was possible. It might be good for obfuscation job security, though. Wink)

Thanks jackal for that crarification...
ill try ty remember to use english in codes...
4  Game Development / Newbie & Debugging Questions / Little problem on: 2007-11-18 16:31:29
Image (donut) doesnt drop normally... but if i press buttons it drops little bit in every press

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
     package org.me.hello;

     import java.applet.*;
     import java.awt.*;
     import java.awt.event.*;
         
     public class peli extends Applet implements KeyListener,Runnable {
         
     Font fontti = new Font("Helvetica", Font.BOLD,  20);    
     
     Image homer;
     Image homerv;      
     Image sydan;
     Image donut;
     
     int aika=0;
     int aks;
     int x,y;
     int pisteet,livet;
   
     public boolean oikee;
     public boolean vasen;
     public boolean tippuu;
     public boolean focus;
         
     private Thread thread =new Thread(this);
                 
     public void run(){            
                     
     while (true) {
         
     try{                    
     
     Thread.currentThread().sleep(20);
     }catch(InterruptedException e){
     }    
     
     repaint();
         
     }    
     }
     
     public void init(){  
     this.aks=(int)(4*Math.random()*100+4);      
     addKeyListener(this);
     setBackground(Color.BLACK);
     donut = getImage(getDocumentBase(),"donutti.png");
     homer = getImage(getDocumentBase(),"homer.png");
     homerv = getImage(getDocumentBase(),"homerv.png");
     sydan = getImage(getDocumentBase(),"sydan.png");    
     resize(600,400);
     livet = 4;
     x=175;
     y=-70;
     }
             
     public void keyPressed(KeyEvent e) {
   
          if (e.getKeyCode() == KeyEvent.VK_ENTER) {
             tippuu = true;            
          }
         
          if (e.getKeyCode() == KeyEvent.VK_LEFT) {
             vasen = true;
          }
         
         
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
             oikee = true;
          }
         
     if(oikee == true){
     if(x<350)x = x+10;
     }
             
         
     if(vasen == true){
     if(x>0)x = x-10;
     }
         
     if(tippuu==true)y = y +5;    
         
     repaint();
     }
     
     public void keyReleased(KeyEvent e) {
     
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
              oikee = false;
          }
         
          if (e.getKeyCode() == KeyEvent.VK_LEFT) {
              vasen = false;
          }                      
     }
           
    public void actionPerformed(ActionEvent e) {}
   
     public void alas(){
               
     }
     
     public void paint(Graphics g) {
     
     g.setColor(Color.red);
     g.drawRect(450,1,5,1000);
     g.setFont(fontti);
     g.drawString("Lives:",470,50);
     
     if(livet > 1){
     g.drawImage(sydan,470,65,30,30,this);
     }
     
     if(livet > 2){
     g.drawImage(sydan,500,65,30,30,this);
     }
     
     if(livet > 3){
     g.drawImage(sydan,530,65,30,30,this);
     }
     
     g.drawString("Points:"+pisteet+"",470,130);
         
     if(vasen==false){    
     g.drawImage(homer,x,313,83,100,this);
     }
   
     if(vasen==true){
     g.drawImage(homerv,x,313,83,100,this);              
     }
     
     g.drawImage(donut,aks,y,50,50,this);
     }
     
    public void keyTyped(KeyEvent e) {
    }
    }
5  Game Development / Newbie & Debugging Questions / Re: Whats wrong whit code? on: 2007-11-16 16:24:27
now i have an new problem:
image(donut) isnt walling normally... how do i fix this problem?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
     package org.me.hello;

     import java.applet.*;
     import java.awt.*;
     import java.awt.event.*;
         
     public class peli extends Applet implements KeyListener,Runnable {
             
     Font fontti = new Font("Helvetica", Font.BOLD,  20);    
     
     Image homer;
     Image homerv;      
     Image sydan;
     Image donut;
     
     int äks;
     int x,y;
     int pisteet,livet;
   
     public boolean oikee;
     public boolean vasen;
     public boolean tippuu;
     
     public void run(){            
                     
     while (true) {
                         
     repaint();
         
     }    
     }
     
     public void init(){
     this.äks=(int)(4*Math.random()*100+4);      
     addKeyListener(this);
     setBackground(Color.BLACK);
     donut = getImage(getDocumentBase(),"donutti.png");
     homer = getImage(getDocumentBase(),"homer.png");
     homerv = getImage(getDocumentBase(),"homerv.png");
     sydan = getImage(getDocumentBase(),"sydan.png");    
     resize(600,400);
     livet = 4;
     x=175;
     y=-70;
     }
             
     public void keyPressed(KeyEvent e) {
   
          if (e.getKeyCode() == KeyEvent.VK_ENTER) {
             tippuu = true;            
          }
         
          if (e.getKeyCode() == KeyEvent.VK_LEFT) {
             vasen = true;
          }
         
         
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
             oikee = true;
          }
         
     if(oikee == true){
     if(x<350)x = x+10;
     }
             
         
     if(vasen == true){
     if(x>0)x = x-10;
     }
                   
     repaint();
     }
     
     public void keyReleased(KeyEvent e) {
     
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
              oikee = false;
          }
         
          if (e.getKeyCode() == KeyEvent.VK_LEFT) {
              vasen = false;
          }
     }
           
    public void actionPerformed(ActionEvent e) {}
   
     public void alas(){
               
     }
     
     public void paint(Graphics g) {
     
     g.setColor(Color.red);
     g.drawRect(450,1,5,1000);
     g.setFont(fontti);
     g.drawString("Lives:",470,50);
     
     if(livet > 1){
     g.drawImage(sydan,470,65,30,30,this);
     }
     
     if(livet > 2){
     g.drawImage(sydan,500,65,30,30,this);
     }
     
     if(livet > 3){
     g.drawImage(sydan,530,65,30,30,this);
     }
     
     g.drawString("Points:"+pisteet+"",470,130);
         
     if(vasen==false){    
     g.drawImage(homer,x,313,83,100,this);
     }
   
     if(vasen==true){
     g.drawImage(homerv,x,313,83,100,this);              
     }
     
     g.drawImage(donut,äks,y,50,50,this);
     if(tippuu==true);
     }
     
    public void keyTyped(KeyEvent e) {
    }
     }
6  Game Development / Newbie & Debugging Questions / Re: Whats wrong whit code? on: 2007-11-13 18:26:07
First, you have to add the KeyListener in the init method.  I realize that the class is the Applet and the KeyListener, but you still have to add it.  Add the line "addKeyListener(this);" to the init method.

Also, it looks like your if statements in the paint method have "=" in them.  If statements should always use "==" for boolean comparison.  I'm surprised that code even gets past the compiler.

Additionally, instead of checking the right key twice, you probably want to check the left key and the right key.

That should be enough to get the image moving, but there are some other improvements you should make.  You should only load the images in the init method and store them in variables to be used by the paint method.  In general, you shouldn't include anything except painting in the paint method.  In fact, you should remove the coordinate updating from the paint method and put it in the keyReleased method, eliminating all the code that's in the keyPressed and keyReleased methods, as well as eliminated the booleans.

doesnt work..
new code:

     package org.me.hello;

     import java.applet.*;
     import java.awt.*;
     import java.awt.event.*;
         
     public class peli extends Applet implements KeyListener {
     
     Image ukko;   
     Image karkki;
     Image tikkari;
     int x,y;
     public boolean oikee;
     public boolean vasen;
     
     public void run() {
   
     while (true) {

     repaint();
         
     }   
     }
     
     public void init(){
     addKeyListener(this);
     tikkari = getImage(getDocumentBase(),"tikkari.png");
     karkki = getImage(getDocumentBase(),"karkki.png");
     resize(600,400);
     x=300;
     y=350;
     }
       
     public void keyPressed(KeyEvent e) {
     
          if (e.getKeyCode() == KeyEvent.VK_LEFT) {
             vasen = true;
          }
         
         
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
             oikee = true;
          }
         
     if(oikee == true){
     x = x+2;
     }
             
         
      if(vasen == true){
     x = x+2;
     }   
         
     Image tausta;
     }
     
     public void keyReleased(KeyEvent e) {
     
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
              oikee = false;
          }
         
          if (e.getKeyCode() == KeyEvent.VK_LEFT) {
              vasen = false;
          }
     }
           
    public void keyTyped(KeyEvent e) {}
    public void actionPerformed(ActionEvent e) {}
     
     public void paint(Graphics g) {
 
     g.drawImage(karkki,x,y,50,50,this);
   
     } 
     }
7  Game Development / Newbie & Debugging Questions / Whats wrong whit code? on: 2007-11-13 16:29:48
Why image doesnt move?


     package org.me.hello;

     import java.applet.*;
     import java.awt.*;
     import java.awt.event.*;
         
     public class peli extends Applet implements KeyListener {
     
     Image karkki;
     Image tikkari;
     int x,y;
     public boolean oikee;
     public boolean vasen;
     
     public void run() {
   
     while (true) {

     repaint();
         
     }   
     }
     
     public void init(){
     resize(600,400);
     x=200;
     y=350;       
     }
       
     public void keyPressed(KeyEvent e) {
     
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
             vasen = true;
          }
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
             oikee = true;
          }
     }
     
     public void keyReleased(KeyEvent e) {
     
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
              oikee = false;
          }
          if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
              vasen = false;
          }
     }
           
    public void keyTyped(KeyEvent e) {}
    public void actionPerformed(ActionEvent e) {}

     
    public void oikee(boolean b) {
    if(b == true){
    x = x+2;           
    }
    }

    public void vasen(boolean b) {
    if(vasen == true){
    x = x-2;
    }
    }
     
     public void paint(Graphics g) {
     tikkari = getImage(getDocumentBase(),"tikkari.png");
     karkki = getImage(getDocumentBase(),"karkki.png");
     if(oikee = true){
     x = x+2;
     }
     if(vasen = true){
     x = x+2;
     }
 
     g.drawImage(karkki,x,y,50,50,this);
   
     } 
     }
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (17 views)
2014-09-19 03:14:18

Dwinin (34 views)
2014-09-12 09:08:26

Norakomi (61 views)
2014-09-10 13:57:51

TehJavaDev (84 views)
2014-09-10 06:39:09

Tekkerue (42 views)
2014-09-09 02:24:56

mitcheeb (64 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (39 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!