Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
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 / Showcase / Re: Cubic on: 2013-07-22 23:52:36
Above problem should now be taken care of!
2  Games Center / Showcase / Re: Cubic on: 2013-07-19 13:03:43
Hmmm, that feels weird.  Could you please provide a screenshot?


Hey Dals!

The images look great!
But it isn't quiet running on my Android Samsung GT-S5830i.
It seems like the resolution isn't correct.
At the title screen, the Logo is only half displayed, and ingame you can only go up!
3  Games Center / Showcase / Cubic on: 2013-07-18 13:12:23
EvaD Interactives Ludum Dare (26) entry has now been completed.
It is a runner and the main goal is to come as far as possible!


It is available for free on Google Play here,
https://play.google.com/store/apps/details?id=se.evad.main

All feedback is appreciated Cheesy

~Dals with team.
4  Games Center / Showcase / Re: Colours on: 2012-11-19 20:16:10
The lite version of this app is now available Cheesy

Please test it out and if you like it share it with your friends and rate it  Smiley
5  Games Center / Showcase / Re: Colours on: 2012-11-18 22:13:03
This forum uses BBCode so you would want to do something like:

1  
[url=http://play.google.com/store/apps/details?id=se.dalsit.colour][img]http://developer.android.com/images/brand/en_generic_rgb_wo_60.png[/img][/url]


Regarding the game: thank you! I've been wanting to practice my RGB kung-fu abilities. Unfortunately, I'm broke and can't even pay $1 for this app Emo
Thanks! I did not know that. PM me with an email adress and I will send you a free copy Smiley
6  Games Center / Showcase / Colours on: 2012-11-18 22:02:23


My first game for android is finally released. It is called Colours and basically what you should do is to match a random colour with the help of the R G B values.

Colours is a new unique puzzle game that focus on colours.
Your objective is to match the colour that is randomly generated on every level.
If you do it fast you will gain more point!

The game becomes harder and harder for every level! And everything is on the clock.
The faster you do it the more points and time will you get.

The goal is to complete as many levels as possible to archive the top position on the high score list.


If you want you can try it out here:




Lite version:





If you want to know more about me or colours:

Follow me at my site www.dalsgames.dalsit.se
or on Twitter @DalsGames


7  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-29 00:42:35
Thanks for the link! It seems like a valuable resaure. Also thans for the exemple! I'll have to try to implement this into my game Smiley
8  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-28 20:19:18
Okey guys! I feel a little lost now! You talking about some funky raycasting and stuff Smiley
Of what I understood from your replays was that it was difficult to calculate the collisions and when to stop which velocity due to my world implementation? Have I understood you right? Smiley

What I want is a simple platformer with the basic movement and physics Smiley
9  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-26 13:43:17
Hmm, the way that my world is implemented is on the first post.
You mean that  I should check this every time I move?
I'll will have to think about how I should implement this collision testing but if you could help me I would be very glad Cheesy
TIA!
10  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-25 13:46:09
Ah, for collision detection?

You'd put a check where the comment "//change position by velocity" is in the prior code. Otherwise you're moving the character twice (I'm assuming that you're checking after you've run the update code, which means you're adding velocity.x/y twice, and the second time without applying the delta.)


Well this is how I've done it this far:

in my frame class I've the detection of collision... (It has to be here due to the way I draw my world.)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
 private boolean checkCollision () {
       
        for (int n = 0; n < map.getBlocks().size();n++) {
           
            if (player.getBounds().intersects(map.getBlocks().get(n).getBounds())) {
           

               return player.collision = true;
            }
          }
         
          return player.collision = false;
         
      }


      Then I my hero class I have:
   
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
 public void setIsOnGround ()  {
     
      if (collision == true) {
         isOnGround = true;
         
         
      } else {
         updateGravity (0.5f); //<- stops the player from falling trhough blokcs in some way!
        isOnGround = false;
         
         
      }  
   }

 
   


   And in my gameUpdate method I have this
1  
2  
3  
4  
5  
6  
7  
8  
9  
// updates the game
     
       
       checkCollision ();
       player.setIsOnGround();
       player.update(0.5f);
       
       
       gameRender ();



The overrided physical entity method in my hero class :
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  
   @Override
   public void update (float delta) {
     
      //apply friction
       if (isOnGround){
            velocity.x *= 1.0f - ((1.0f - GROUND_FRICTION) * delta);
            velocity.y *= 1.0f - ((1.0f - GROUND_FRICTION) * delta);
        }
        else{
            velocity.x *= 1.0f - ((1.0f - AIR_FRICTION) * delta);
            velocity.y *= 1.0f - ((1.0f - AIR_FRICTION) * delta);
        }
       
       
       
        if (collision == true )  {
           velocity.x = 0;
           velocity.y = 0;
           //GRAVITY.x = 0;
          //GRAVITY.y = 0;
       }
       
       
       

        position.x += velocity.x * delta;
        position.y += velocity.y * delta;
        }









With this code I've managed to get it to stop when it hits a block from above due to the gravity... but when I hit a block I get stuck and can't move. What should happen to the gravity and the two booleans (collision,isOnGround) when the object hit a block?



 Any suggestions? Smiley









11  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-25 03:28:11
Hey again! I was able to implement the physics and it workes fine!
But what would progaming be whiteout some problem! Tongue
As I said the movement is perfect but now my collision detecion get screwed up by using this new vector class that you wrote for me.

My bounding rectangle before was created like this:
1  
2  
3  
4  
5  
   public Rectangle getBounds () {
       Rectangle r ;
       r = new Rectangle (positionX +x ,positionY +y ,width,height);
       return r;
    }

This worked like a charm because the bounding rectangle would move before the player which would make the collision perfect.

I've tried to implement this this collision detecion with the new physics code like this :

1  
2  
3  
4  
5  
  public Rectangle getBounds () {
       Rectangle r ;
       r = new Rectangle ((int)position.x + (int) velocity.x,(int) position.y + (int)velocity.y, width, height);
       return r;
    }


but I'm not able to get it to work! Do you have any suggestion on how I should do this insteed?

p.s sorry about my grammar, it's kinda late xD


12  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-23 21:36:30
Ohh, well! loads of new code to understand and learn Cheesy Thanks alot guys for trying to help me out!
If I get stuck I'll ask away Smiley

Thanks again!
13  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-23 19:02:02
Okay! Yeah that sounds pretty logic.. do you think I should change the code for the left and right movement aswell?
I'm not completly sure how to implement the velocity for the movement so if you could point me in the direction (I know that you already given my a hint) Cheesy
14  Game Development / Game Mechanics / Re: Basic platform movement and gravity on: 2012-02-23 18:08:16
call move before you paint it or else there will be a lag effect.
Could you be a bit more specific on how your movement isn't "good"?

Hi, thanks for your replay!

I've changed the code so the move method is before the draw method in my gameUpdate but I didn't notice something.

Well what I ment was that the movement fells very choppy and unnatural... do you have any advice?

15  Game Development / Game Mechanics / Basic platform movement and gravity on: 2012-02-22 22:13:55
Hello!

I'm working on a very basic platform engine. This is my first attempt so please excuse me for sloppy programming pratice and such  Tongue
I've got a working platform engine. A player that moves and a "world" loaded from a file.

My problem is that the movement and physics isn't that good and i really don't like how it looks.
I'd like to know what to do with the code to get a smooth movement and physics that works properly!
I've implemented collision detecion, which I think works okay but if someone thinks diffrently please explain what I should do to make it better.

If someone helps me out with this it would help my out alot Cheesy


So time for some code Smiley

My Frame class (The main class)

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  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.swing.JFrame;


public class Frame extends JFrame implements Runnable,KeyListener {

   
   private static final long serialVersionUID = 1L;
   
   // SCREEN VARIABLES
  int screenWidth  =640;
   int screenHeight =480;
   
   // world objeccts and variables
 
   Map map;
    Block blocks;
   
   
   // Graphicsh
  BufferedImage backBuffer;
   ImageEntity background;
   Graphics2D g2d;
   
   // animated sprite variable
  //AnimatedSprite player;
 
   // Hero variables
  AnimatedSprite hero;
   Hero player;
   
   
   int playerX = 320;
   int playerY = 100;
   int moveX,moveY;
   
   boolean collision = false;
   int  test = 0;
   // world physics variables
  long TimeStart,TimeEnd;
   
   
   // Fps variables
  int frameCount = 0;
   int frameRate = 0;
   long startTime = System.currentTimeMillis();
   int desierdRate = 60;
   
   // Threads
  Thread gameloop;
   
   
   public static void main(String[] args) {
      new Frame();
   }
   
    Frame () {
       
       // Basic GUI STUFF
      super ("The Diary");
       setSize (screenWidth,screenHeight);
       setVisible (true);
       setResizable (false);
       setDefaultCloseOperation (3);
       
   
       
       // Create a backbuffer so the screen wont flicker like hell!
      backBuffer = new BufferedImage (screenWidth,screenHeight,BufferedImage.TYPE_INT_RGB);
        g2d = backBuffer.createGraphics();
        background = new ImageEntity (this);
        background.load("bluespace.png");


        // Hero
       player = new Hero (32,32);
        player.showBounds(true);
       // player.setGravity(5);
       
        //map
       map = new Map("maze.txt");
       
     
           
       
         
       
        // skapar och startar min tråd
       gameloop = new Thread (this);
        gameloop.start();
        addKeyListener (this);
   
               
       

     }
   
    public void run () {
       Thread t = Thread.currentThread();
       
        try {
         map.createMap();
      } catch (IOException e) {
         
         e.printStackTrace();
      }
   
       
       
       while (t == gameloop) {
          try {
             Thread.sleep(1000 / desierdRate);
          } catch (InterruptedException e) {
             e.printStackTrace();
          }
         
          gameUpdate ();
          repaint ();
       }
    }
   

    // Game update here is it where the magics happends
 
    void gameUpdate ()  {
   
       // räknar ut FPS
      log ("FPS :"+ frameRate);
       frameCount++;
       if (System.currentTimeMillis() > startTime + 1000) {
          startTime = System.currentTimeMillis();
          frameRate = frameCount;
          frameCount = 0;
       }
       
       
       // backgrouunds bilden
      g2d.setColor(Color.GRAY);
       g2d.fill(new Rectangle (0,0,screenWidth-1,screenHeight-1));
       
        // rita ut alla blocks
     
       for (Block b : map.getBlocks()) {
         b.draw(g2d);
         
      }
     
       checkCollision () ;
       player.draw(g2d);
       player.move();
       
   
       
       // Draw debug info
      g2d.setColor(Color.WHITE);
       g2d.drawString("FPS: "+ frameRate, 50, 50);
       g2d.drawString("Player X" + player.positionX, 50,70);
        g2d.drawString("Player Y"+ player.positionY, 50, 80);
        g2d.drawString ("Collison:" + player.collision,50,100);
        g2d.drawString("Falling: " +  player.falling, 50, 110);
       
       
         
    }
   
   
   
    private boolean checkCollision() {
   
       for (int n = 0; n < map.getBlocks().size();n++) {
         
          if (player.getBounds().intersects(map.getBlocks().get(n).getBounds())) {
         

             return player.collision = true;
          }
        }
       
        return player.collision = false;
       
    }


   
   public void paint (Graphics g) {
        //paint the backBuffer
      g.drawImage(backBuffer, 0, 0, this);
    }

   

     


   public void keyPressed(KeyEvent e) {
      switch (e.getKeyCode()) {
      case KeyEvent.VK_LEFT:
         player.setX(-5);
         
         break;
     
      case KeyEvent.VK_RIGHT:
         player.setX(5);
   
         break;
      case KeyEvent.VK_UP :
     
      player.setGravity(0);
       player.setY(-50);
         
         break;
   
      case KeyEvent.VK_SPACE:
         player.positionX = 150;
         player.positionY = 150;
         break;
     
   
      }
     
     
   }

   
   public void keyReleased(KeyEvent e) {
      switch (e.getKeyCode()) {
      case KeyEvent.VK_LEFT:
        player.setX(0);
        //player.setGravity(5);
        break;
      case KeyEvent.VK_RIGHT:
        player.setX(0);
        //player.setGravity(5);
        break;
      case KeyEvent.VK_UP:
         player.setY(0);
         player.setGravity(5);
         break;
           
     
     
      }
     
   }
   public void keyTyped(KeyEvent e) {
     
     
   }
   
   public void log(String s) {
      //System.out.println (s);
  }
   
   
   


}


My Hero class :

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  
import java.awt.*;


public class Hero {

   int positionX,positionY,x,y;
   int width,height;
   int gravity;
    boolean drawBounds;
    boolean collision,falling ;
   Map m;
   
   
   // konstruktör
  Hero (int width,int height) {
      positionX = 150;
      positionY = 150;
      this.width = width;
      this.height = height;
      drawBounds = false;
   }
   
   // riitar ut objectet
  public void draw (Graphics2D g2d) {
      g2d.setColor(Color.BLACK);
      g2d.fillRect(positionX, positionY, width, height);
     
      if (drawBounds == true) {
         g2d.setColor(Color.RED);
         g2d.drawRect(positionX + x , positionY +y, width, height);
      }
   }
   
   // collision detections rectangle som är en aning före obejctet!
   public Rectangle getBounds () {
       Rectangle r ;
       r = new Rectangle (positionX +x ,positionY +y ,width,height);
       return r;
    }
   
   
   // en setter som talar om om man vill visa collsionrectangle
  public void showBounds(boolean b) {
      drawBounds = b;
   }
   


   
   public void setX (int x) {
      this.x = x;
   }
   public void setY (int y) {
      this.y = y;
   
   }
   
   
   public void move () {
      if (collision == true) {
            setGravity (0);
            x = 0;
            y = 0;
      }
     
      if (y > 0) {
         falling = true;
      } else  {
         falling = false;
      }
     
      if (x > 0 || x< 0 && collision == false) {
         setGravity (5);
      }
     
     
      positionX +=x;
      positionY +=y;
      gravity();
     
     
     
   }

   public void setGravity (int gravity){
      this.gravity = gravity;
   }
   
   private void gravity () {
         setY (gravity);
   
    }
       
         
   }
   


If needed my block class and world class
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  
import java.awt.*;

import javax.swing.ImageIcon;
public class Block {

   int width,height,x,y;
   Image BLOCK_WALL;
   
   public Block (int x, int y) {
      this.x = x;
      this.y = y;
      width  = 20;
      height = 20;
       BLOCK_WALL = new ImageIcon ("D:/Programmering/Projekt/Workspace/Framework/src/block_wall.png").getImage();
   }
   
   public void draw (Graphics2D g2d) {
      g2d.drawImage(BLOCK_WALL, x, y, width,height,null);
      g2d.setColor(Color.RED);
      g2d.drawRect(x, y, width, height);
   }
   public Rectangle getBounds() {
      Rectangle r;
      r = new Rectangle  (x,y,width,height);
       return r;
   }

}


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  
import java.util.*;
import java.io.*;

public class Map {

   ArrayList <Block> blocks;
   String filePath;
   
   
   public Map (String path) {
      filePath= path;
      blocks = new ArrayList<Block>();
   }
   public void createMap () throws IOException {
     
      ArrayList <String> lines = new ArrayList <String>();
     
      BufferedReader r= new BufferedReader (new FileReader (filePath));
     
      while (true) {
         String line = r.readLine();
         
         if (line == null) {
            r.close();
            break;
         }
         else {
            lines.add(line);
         }
      }
     
      for (int y = 0; y < lines.size(); y++) {
         for (int x = 0; x<lines.get(y).length();x++) {
            // laddar in mapppen med x och y värden
           
            char mark = lines.get(y).charAt(x);
           
           
           
            if (mark == '#') {
               blocks.add(new Block (x*20,(y*20)+25));
            }
         }
        }
      }
   
      public ArrayList <Block> getBlocks () {
         return blocks;
      }
     
     
     
   
}


I'm new to this fourm so please excuse me if I've posted in the wrong forum and for my unbelievable long post x)

Thank in advance!
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.

xsi3rr4x (25 views)
2014-04-15 18:08:23

BurntPizza (20 views)
2014-04-15 03:46:01

UprightPath (36 views)
2014-04-14 17:39:50

UprightPath (18 views)
2014-04-14 17:35:47

Porlus (34 views)
2014-04-14 15:48:38

tom_mai78101 (60 views)
2014-04-10 04:04:31

BurntPizza (118 views)
2014-04-08 23:06:04

tom_mai78101 (218 views)
2014-04-05 13:34:39

trollwarrior1 (185 views)
2014-04-04 12:06:45

CJLetsGame (192 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!