Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  Java Game APIs & Engines / Java 2D / Re: rendering tiles w/ static render method on: 2012-06-09 23:49:01
changing the filter calls worked

(now I get max fps)

 Wink
2  Java Game APIs & Engines / Java 2D / Re: rendering tiles w/ static render method on: 2012-06-07 11:38:56
thanks! I'll try to see what I can do and report back

(especially about the design patterns bit)
3  Java Game APIs & Engines / Java 2D / Re: rendering tiles w/ static render method on: 2012-06-07 01:54:13
thanks for the tips, but I tried using startUse(), drawEmbedded() and endUse() but I still get some fps drops

it's not so much that I'm receiving low fps at the moment with my current rendering technique but the fact that if I want to call multiple render methods for every tile as an "object" the fps will drop insanely
4  Java Game APIs & Engines / Java 2D / rendering tiles w/ static render method on: 2012-06-06 22:34:54
I'm not sure how to go about rendering tiles "properly", if I were to create each tile as an individual object and call its render method -- the game's fps would drop dramatically (to about 20fps or so)

at line 76:
https://github.com/codecub/slicktest/blob/master/tribelife/src/Slick.java
(tile rendering method)

see Grass.java:
https://github.com/codecub/slicktest/blob/master/tribelife/src/Grass.java

so yeah: "Is there a better way to render tiles individually?"

I believe the problem lies in the fact that whenever I create an object out of a grass tile, calling "different rendering methods" (different objects w/ same render method, new instance) really slows down the rendering altogether

should I just create a static render method? how will it then take into account individual tile object data (x, y etc)?


(21x15, 27*27 tile size)

and yeah, I know slick2d contains a tilemap library (but still)
5  Games Center / Featured Games / Re: Tropical Stormfront (RTS) on: 2012-03-25 21:44:13
better than most games on here  Shocked
6  Java Game APIs & Engines / Java 2D / Re: Java 2D - My Rpg Game So Far on: 2012-03-25 18:43:29
seems legit
7  Game Development / Newbie & Debugging Questions / Re: Moving around on a map? on: 2012-03-24 23:13:01
you'd just render the whole map as you normally would and move the 'map' (so to speak) whenever your player 'moves'

in essence: your player doesn't move, but the map does (creates an illusion of player movement)

8  Game Development / Performance Tuning / Re: fast box blur algorithm on: 2012-03-24 13:11:42
I think you mean ==.  I'm open minded, if you want to be a large bundle of sticks then go you.

== isn't a declaration operator, just an equality one Shocked
9  Games Center / Showcase / Re: 2x2 - multiplication puzzle game on: 2012-03-24 02:31:20
10  Game Development / Performance Tuning / Re: fast box blur algorithm on: 2012-03-24 02:28:46
I know this is an old thread, but generally:

int a = 0;

void derrfunction(){
++a = 1;
a++ = 0;
}

it's incredibly asinine to argue about its speed though (like, it does NOT matter at all whatsoever), but it definitely feels better to know when to utilize the proper increment operators at any given time
11  Game Development / Performance Tuning / Re: Best motion algorithm on: 2012-03-24 02:26:01
12  Discussions / General Discussions / Re: How Long Have You Been Coding? on: 2012-03-19 01:41:07
2 years
13  Discussions / General Discussions / Re: The Art of Video Games Exhibition on: 2012-03-19 01:34:56
Chris-chan?  Huh
14  Games Center / Archived Projects / Re: Skyfall on: 2012-03-18 18:01:32
f**king awesome!@@@
15  Game Development / Game Play & Game Design / Re: smoother x/y-axis increments on: 2012-03-18 13:11:57
Thanks, all. I'll try out some of your solutions and report back.

edit: I found a solution by using the delta*moveSpeed method.
16  Game Development / Game Play & Game Design / Re: smoother x/y-axis increments on: 2012-03-18 03:05:47
...
Or if you're using a 'double':
1  
2  
3  
4  
5  
   public void move() {
      if (player.movingRight()) {
         player.absX = player.absX += 0.1;
      }
   }


If that's not what you're looking for let me know.

I am referring to faster increments of the x/y-axis.

If you're using any sort of timer that updates (or allows updating) of the sprite position when time's up, then you can just use the speed of the sprite to calculate the new timer time.  Each sprite would need it's own timer, but that's normal.

not sure how that would play out, maybe if I were to increase the time depending on how long the key is held? I'm mainly having trouble increasing the value by 1 fast enough so that I can move at a fast pace but still prevent choppiness

it's like basically trying to scroll over 200 pixels when you could just increment by like 50 pixels and get there extremely quickly whereas you'd increment by 1 pixel very quickly and get there as quick (except not producing a choppy, 'bursty' travel)
17  Game Development / Game Play & Game Design / smoother x/y-axis increments on: 2012-03-18 02:45:40
Is there a way to increment the x/y coordinates of a render smoothly by merely just incrementing it by 1 'faster'?

I've come across situations in which I am changing the speed/rate of travel of an object by just adding a larger value to the x/y coordinates of said object

so, something like

x += 5;

would make it appear to go faster but instead result in choppy rendering (since you're adding a large value like 5 instead of progressively adding values of 1)

in essence:

is there a way to 'speed up' incrementing by 1 (ie. ++x) in order to reduce choppiness when changing the rate of travel of an object?
18  Game Development / Newbie & Debugging Questions / Re: <List> add question on: 2012-03-16 16:22:26
edit: I was creating a new instance of an object of the same type, so in passing the same object (without referencing another one) it'll add/render the entity properly

thx OP
19  Game Development / Newbie & Debugging Questions / Re: <List> add question on: 2012-03-16 16:10:14
How is Screen.render being called? Are you using active or passive drawing on your component? If it is passive then you have to call repaint() on your root container.
Active (I didn't want to post the screen code because it shouldn't matter whether or not it appears but whether or not the entities.size increases)
Where do you set removed to false? That could be the problem.
On definition removed is false, but it doesn't matter since I only want to see an increase in entities.size.
If it works when entities is static but doesn't work anymore when it's not static then you must have more then one Screen object and you add the entity to the wrong one.
I don't know what you mean by that
20  Game Development / Newbie & Debugging Questions / <List> add question on: 2012-03-16 01:43:56
I am trying to add a 'ball' entity with my mouse coordinates within my mouse class, however whenever I try to make a non-static reference in order to 'add' the ball it won't increase the entity size (not adding on the screen).

Mouse.java:
1  
2  
3  
public void mousePressed(MouseEvent e) {
   s.addEntity(new Ball(e.getX(), e.getY(), 15, 15));
}


Ball.java:

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


public class Ball extends Entity{
   private int x, y, width, height;
   private boolean removed;
   
   public Ball(int x, int y, int width, int height){
      this.x = x;
      this.y = y;
      this.width = width;
      this.height = height;
   }
   
   public void render(Graphics g){
      if(!removed){
         g.setColor(Color.WHITE);
         g.drawRect(x, y, width, height);
      }
   }
   
   public void remove(){
      removed = true;
   }
   
}


Screen:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
import java.awt.Color;
import java.awt.Graphics;
import java.util.*;

public class Screen {
   public List<Entity> entities = new ArrayList<Entity>();
   
   public void render(Graphics g){
      System.out.println(entities.size());
      for(int i = 0; i < entities.size(); i++){
         entities.get(i).render(g);
      }
   }
   
   public void addEntity(Entity e){
      System.out.println("ADDED" + e);
      entities.add(e);
   }

}


Making entities static works, but there must be another way around this?
21  Game Development / Newbie & Debugging Questions / Re: Stupid Sorting Question on: 2012-03-10 21:55:42
find smallest value, store it into another array and reset original value and continue sorting
22  Java Game APIs & Engines / Java 2D / Re: Getting rid of trails? on: 2012-03-05 01:46:44
where is g.clearRect(0, 0, width, height); ?
I dunno.

Also it's best if you use a BufferedImage instead of VolatileImage, since the latter is so unreliable.
Ok, thanks!
23  Java Game APIs & Engines / Java 2D / Getting rid of trails? on: 2012-03-05 01:13:22
I know this is all related to double buffering and stuff but I'm trying to use createVolatileImage to draw some stuff on screen, however - there are trails being left behind. I've tried to get rid of them by clearing over the background image over the drawing but it doesn't work.

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  
package _game;

import java.awt.*;
import javax.swing.JFrame;

public class _game extends Canvas implements Runnable {

*/
   private Thread t = new Thread(this);

   private boolean running;
   
   private static int width = 160;
   private static int height = 120;
   private static int scale = 4;
   
   public mouse mouse = new mouse();
   private Screen screen = new Screen();
   
   private long lastTime;
   public static int tick;
   
   public _game(){
      int w = width * scale;
      int h = height * scale;
     
        setPreferredSize(new Dimension(w, h));
        setMaximumSize(new Dimension(w, h));
        setMinimumSize(new Dimension(w, h));
        setBackground(Color.BLACK);  
       
      addMouseListener(mouse);
      addMouseMotionListener(mouse);
     
        this.setFocusable(true);
   }
   
   public void start(){
        lastTime = System.currentTimeMillis();
       
      running = true;
       
      t.start();
   }
   
   public static void main(String[] args){
      _game ga = new _game();
     
     
     
        JFrame frame = new JFrame("derr");
        frame.add(ga);
        frame.pack();
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
     
      ga.start();
   }

   public synchronized void stop(){
      running = false;
   }
   
   public void paint(Graphics g)
   {
   }

    public void update(Graphics g)
    {
        render(g);
    }
   
   public void render(Graphics g){

   }

   @Override
   public void run() {
      Image image = null;
     
      while(running){
         tick = ((int)(System.currentTimeMillis() - lastTime)/100);
         
         if(image == null){
            image = createVolatileImage(width * scale, height * scale);
         }
         
         Graphics g = image.getGraphics();
         
         screen.render(g, mouse.mx, mouse.my);
         
         g = getGraphics();
         
         g.drawImage(image, 0, 0, width * scale, height * scale, 0, 0, width * scale, height * scale, null);
         g.dispose();

            try
            {
                Thread.sleep(5);
            }
            catch (InterruptedException e)
            {
               e.printStackTrace();
            }
      }
   }
   

}


screen.render(g) just draws rectangles at my mouse pos (when it is dragged)
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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (50 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (57 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!