Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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 / Android / Re: Publishing. Do you need a business? on: 2013-05-20 01:57:26
Wow... the signup was quicker than writing this post...
2  Java Game APIs & Engines / Android / Re: Publishing. Do you need a business? on: 2013-05-20 01:03:32
You can act as an individual. You should be able to follow the steps easily to publish your app.

Brilliant. Cheers.

If you want to pay the absolute maximum amount of tax over your sales, then yes, sell it as an individual.

Point noted Riven, thanks.

But you might want to, yunno, actually try selling something before you worry too much about your liabilities, and only then plow the first few hundred quid you make into some incorporation paperwork.

Spot on sproingie. This is pretty much where I'm coming from, I just want to give it a whirl as an individual first. If I make $2 then I won't worry about establishing a business and paying VAT in some European country I've never heard of. If however I woke up $100K richer (...ya...right...sure...), then I'd be applying for that business number and giving an accountant a call.

Cheers all, much appreciated.
nerb.
3  Java Game APIs & Engines / Android / Publishing. Do you need a business? on: 2013-05-19 11:43:10
Hi,

Simple question: Do you need to have a registered business to sell paid apps on the Google Play store? Or can you act as an individual? It appears you do if you are in the US or UK, but I am in Australia.

I've had a bit of a googling, and can't seem to easily find an answer. Has anyone here had any experience with this?

Cheers,
nerb.
4  Game Development / Newbie & Debugging Questions / Re: [RPG] How do you move all of these things? on: 2013-05-19 08:01:50
Exactly what DrZoidberg said. Decouple the view from the world.

For example, treat your view as a 'camera', which itself has a position. In your case the camera position is updated when the player position changes, keeping the player in the centre of the screen. When it comes to rendering everything, just convert their world coordinates to 'view' coordinates. In a general case this will be worldCoords - cameraCoords.

It will free you from your issues with screen resizing, unless of course you wanted to implement scaling.

This will make your camera object more versatile and reusable too. For example, you could implement scrolling, or control the camera for certain animations or events. Furthermore, you no longer have to update every object in the world when your player moves; you are just updating the player and camera position.

EDIT: (And a bit off-topic). I see you are working on an RPG. As your game expands in size, you could use this camera approach with your world design to optimize things a bit. For example, with a small game there are no problems iterating through each object and converting world coordinates to screen coordinates, and drawing them if they are within the viewport. However if you had a lot of objects you may end up with a lot of unneeded calculations. You could for example break your world/map up into 'segments'. You could then quickly calculate which segments are currently within or near the viewport, and only do the 'world to screen' calculations for objects that are in those segments, and hence are potentially visible.
5  Game Development / Newbie & Debugging Questions / Re: Editing images on: 2013-05-16 05:10:42
Hi kingroka,

Appears to be a few ways, some which may be more correct than my method. But I usually create a new image like so:

1  
2  
3  
BufferedImage image;

image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);


Then if you wanted to use the Java2d Graphics & Graphics2D classes to draw onto it, you can just grab the image's graphics object like this:

1  
2  
3  
4  
5  
Graphics g;

g = image.getGraphics();
//do some drawing here with g etc.
g.dispose();


To manipulate it 'pixel by pixel' you have a couple of options. One of the simplest is using BufferedImage.getRGB(int x, int y) and BufferedImage.setRGB(int x, int y, int RGB).

Alternatively you can grab the image's 'data buffer' directly as an array. This can be a better approach performance wise, as you don't have the overhead of the get/setRGB() methods. One way to do this is:

1  
2  
3  
4  
int[] imgArray;

imgArray = ((DataBufferInt)image.getRaster().getDataBuffer()).getData()
//Now you can directly mess with the integer RGB values in imgArray[].


Rightly or wrongly, that's generally how I do it...
6  Game Development / Newbie & Debugging Questions / Re: Which of these two level method should I use? :P on: 2013-05-12 02:20:01
Doesn't Android handle it's "Bitmap memory" (as in images) aside from the rest of your apps memory?

In general no, they still come out of your allocated memory and hence count towards your memory limit. Although apparently they don't when using OpenGL like you've suggested.

I'm really not looking forward to learning how to make the map since I'm bad at graphics and stuff like that xD Do any of you guys know a good tutorial on how to code maps in to java games? Smiley

A bit of Googling or Youtubing should give you some idea. There is a few 'map design/format' topics on this forum too. I can't for the life of me think of any good tutorials on it, my apologies.
Edit: And if you do go have a search, don't necessarily limit yourself to 'coding maps in java games'. The general principles are the same for any language.
7  Games Center / WIP games, tools & toy projects / Re: The Woods on: 2013-05-11 10:39:04
I think you've got some really interesting concepts here and I'm looking forward to seeing how they turn out.

My only real suggestion is perhaps changing the font in the inventory screen to something slightly more legible. I understand you are going for the 'handwritten in journal' look, but I reckon reading that font all the time would eventually drive me crazy. (Perhaps it's just me?).

I also wonder if it is enough to keep the player hooked for a long time? What happens once you have built your shelter, gathered enough supplies, and are living a happy little virtual life? Will there be reason to keep playing other than gathering more food? Perhaps you could consider forcing players to be nomadic (i.e. resources are finite), or progressively reward the player with new things to discover and do. Do you have any plans in this respect?

Nonetheless, good job and keep it up.  Cool
8  Game Development / Newbie & Debugging Questions / Re: Which of these two level method should I use? :P on: 2013-05-11 10:06:23
Yep, it can be a big issue on Android. Don't quote me, but on current Android devices you are limited to between 24 and 32MB heap memory, but older devices have as little as 16MB to play with. If you exceed this your app will bail out with an 'out of memory' exception. Large images will chew this up quickly.

If Android is you ultimate aim, then you should probably be looking towards the tile-map approach and re-using textures wherever possible; or at least only loading the segments that you immediately need.
9  Game Development / Game Play & Game Design / Re: Saving and reloading game state on: 2013-05-06 12:12:42
XML works great, but I don't know how I could store it securely on a remote server.

With my limited experience, I would do it like this:
On the server side I would limit the access to the XML file only to specific IP addresses and on the client side I would encrypt the XML file before it is uploaded to the server. However, I don't know if that's the best way to get it done.

Do you need to encrypt it at all? Correct me if I'm wrong, but essentially it is a game save? Providing there isn't any sensitive information contained in it (passwords, contact information, credit cards etc.) I wouldn't stress about encryption, at least from client to server.

Or are you worried about people getting in and modifying it while its on the server? In that case yes, you should certainly limit who & what can access your data/databases, and it should be standard practice. Otherwise you will find all kinds of nasty things happening when you aren't looking, such as your data disappearing completely. But once again I wouldn't panic about encryption, as people should be stopped from accessing it well before encryption comes in to play.

If however you do need to encrypt it for whatever reason, there are a few things to keep in mind. (This is a topic and field of study of its own, of which I know bugger all, but others on here might). If people have access to your client-side application, there is nothing stoping them from decompling it, wading through obfuscation if present, and nutting out your encryption method, and ultimately decoding your file. If the encryption is weak, it will just slow them down a bit. As such you should consider encrypting it again on the server prior to storage, using a different key or method (with the expense of extra performance overhead). You should also be thinking towards using SSL for transmitting the data if it is sensitive, to prevent interception.

But before you do anything like that, consider if 1) Would people would want to intercept & decode the file in the first place, and 2) what are the consequences if they did?

nerb.
10  Game Development / Game Mechanics / Re: Arrow Bow Physics - Help! on: 2013-05-06 11:38:29
G'day Andre,

I recently toyed with a program that involved a ship in orbit around multiple planets. The motion was taking into account gravity, thrust, and ultimately atmospheric drag (although I didn't get around to that). It was all a bit overwhelming at the start, but it became ridiculously simple when using vector math.

So my suggestion is read up on simple vector math if you need to, and then roll your own 2D vector class. Then instead of worrying about parabolas and all that business, it just becomes a case of adding, normalising and multiplying a few vectors (which can be easily contained in a few methods of your vector class).

Then your update loop will essentially be:

1) sum all the acceleration vectors in effect: acceleration = gravity + drag;   [if you are modelling drag, which itself is dependant on velocity, otherwise acceleration = gravity and doesn't change].
2) apply the net acceleration vector to the velocity vector: velocity = velocity + acceleration * deltaTime;
3) apply the velocity vector to your arrow's position: position = position + velocity * deltaTime;
4) repeat in the next loop.

In the above acceleration, gravity, drag and velocity are vectors. deltaTime is a scalar, and position could be treated as a point. It will result in the arrow taking the nice parabolic path that you are looking for.

You just need to set your initial velocity vector prior to launch, which will be influenced by the direction the arrow is pointing in, and its total initial velocity. You would:
1) Normalise the direction vector (i.e. make it a vector in the same direction, but with a total length of 1; done by dividing both x and y by the length).
2) Multiply the normalised vector by the total initial velocity (i.e. It might have a launch velocity of 60m/s, depending on how far back the bowstring is drawn).

Anyway, hope it makes a bit of sense, I'm not the best at explaining things. But if you look into vectors a bit, you should find they make life a lot easier. Let me know if you've got any questions, or want me to dig some code out.

nerb.
11  Game Development / Game Play & Game Design / Re: Destructible/deformable terrain help on: 2013-05-06 10:28:57
Hi,

I just want to try to create a very simple demo/tutorial on how to create a game with destructible/deformable terrain like the good old lemmings or worms.

The problem is that I have no idea where to start. Are there any physics involved? I's like to write a simple level in plain java 2d. I tried to find some examples, but I couldn't.

Any help?

Thanks

Hi luisoft,

Bit of a late reply here.

I asked a very similar question a while back, and got some good answers in the following post:

http://www.java-gaming.org/topics/pixel-based-2d-destructible-terrain/28835/msg/263214/view.html

(Come to think of it, I should go back and appreciate a few of the replies, now I know how).

For the lemmings approach, you can use and manipulate an image for the terrain, and hence have pixel-based destructible terrain. Take note of Rorkien's reply about accessing an image's byte array directly; it's more efficient than messing with get/setRGB().

The only physics involved would be checking the terrain around your 'lemming' and deciding whether he should be falling & splatting, or climbing. A worms clone is obviously a different story, as you then have to handle projectiles and explosions.

Hope it gives you a bit of a starting point.

nerb.
12  Game Development / Newbie & Debugging Questions / Re: What have been/are your learning techniques? on: 2013-04-06 00:12:33
I've just bought myself the book "Head First Java 2nd Edition"

That book is absolute gold. It was my first Java book, and my first book on a 'real' OOP language. Without it, I probably would have given up a long time ago. If there are any complete newbies reading this, take heed of Otreum's recommendation.  Pointing
13  Game Development / Newbie & Debugging Questions / Re: What have been/are your learning techniques? on: 2013-04-03 08:11:37
- Why did you want to start programming? (What was your motivation?)

Mainly because I saw a great opportunity to automate big, tedious tasks at work, and reduce error in tasks with shiploads of numbers involved. I managed to save ridiculous amounts of time, which meant I had more time to smoke and drink coffee.

My motivation then changed once I realised programming is tremendously fun, and the desire to "tinker" with things soon took over.

- Why did you choose to begin with the language you begun with? And if applicable, why are you using the language you are using now?

Technically I began with BASIC when I was a wee child, because a family friend was quite adept at it, and I knew no better. This however was nothing more than creating custom DOS menus etc.

My first 'real' foray into programming was with VBA, as it was the easiest way to interact with major programs I use at work; namely ESRI ArcGIS and the MS Office suite. I still use it when the need arises, but I really dislike it now after spending a lot of time with Java. I'd go as far to say that it is a horrible language that should be avoided, particularly by those starting out (Could this be extended to VB?? Anyone else got an opinion? I've never actually worked with VB, just VBA).

I started learning Java as I wanted to begin writing my own programs. I liked the Java syntax; it seemed logical to me. There also appeared to be plenty of resources available to learn it. It was also a very 'welcoming' language for people starting out, compared to something like C for example. I'm still using Java as I have put most of my time into learning the language.

I've since started learning C, just for the hell of it. Although this is more out of interest, and I've yet to do anything functional with it. It is partly because of an interest in electronics and microcontrollers, which I hope to learn more about when I get some time. I'd also like to play around with the Windows API one day. I'm one of those people that likes to learn things purely for the sake of learning, I enjoy it. However, this unfortunately means I know little about much, not much about little.

I've got a couple of books on Python laying around. I've got no intention of learning it yet, but may get around to it one day. Python is the 'language of choice' for the latest version of ArcGIS, so if I end up working with it I will probably pick up the books sooner than later.

- How long ago did you get started? And where are you at now?

(Java) About 2 or 3 years ago I think. I'm proficient enough that I can usually accomplish what I want to, but not without some help along the way (such as API references, forums such as these, and a book or two). As I'm an enthusiast, not a 'real' programmer, I progress slowly.

I'm considering doing a part-time computer science degree by correspondence in the near future, so hopefully I can one day change that 'enthusiast' title.

- What learning methods did you employ personally to help you develop your skills in programming?

Books! Lots of them. Amazon became my best friend, and ate lots of my money. I'd often purchase multiple books on the same subject as there is always more than one way to skin a cat. I also found if I struggled to understand what one author was saying, another author may describe the problem better. Furthermore, I aimed to get a good mix of 'tutorial' books, and 'reference' books.

Second to that, playing around. I believe the best way to learn is by doing. I'd often discover a concept that I wanted to learn more about (networking, graphics, bits & bytes etc.), so would open up the IDE and begin programming. I'd never have a particular goal in mind, I just liked to mess around and see what I could do. As a result I've got lots of little programs stashed away that explore a particular concept, none of which are very complete or spectacular, but I keep them for future reference.

- What advice could you give to other programmers who might be feeling a little lost in what direction to take?

As mentioned I'm an enthusiast, not a programmer, so I don't really feel qualified enough to give any meaningful advice. The only thing I would say is "Nike: Just do it". If you are stuck on a particular problem and can't wrap you head around it, just start programming and playing around. You'll soon discover what you need to, and hopefully enjoy the process along the way. Not everything can be learnt from a reference.

- Is there anything you believe should be a "Rite of Passage" for programmers?

No. But as a newbie, that glorious moment when you first get animated graphics on the screen is very memorable. Start small and work your way up. Rome wasn't built in a day; nor was SimCity 2000.
14  Games Center / Showcase / Re: Modern Shooter - a very modern FPS game on: 2013-03-13 11:22:31
Quite enjoyed the game Thotep! Perhaps because it took me back to the days of Sierra's Police Quest II. Good job.  Cool
15  Discussions / General Discussions / Re: Highschool Programming on: 2013-03-12 14:58:22
A book won't be that helpful.


...I couldn't disagree more... I've primarily taught myself out of books. And they provide a good reference.
16  Game Development / Newbie & Debugging Questions / Re: When to start trying? on: 2013-03-10 08:05:07
Thanks for the quick reply.
I was exploring the Gaming Wiki right now. I feel like it does not have the most basic stuff as tutorials but has resources to it?

And I feel a little lost when I try to think a way to write a game. How do you guys start writing a new game? What's your starting point?

G'day kutucuk,

I come from a similar background to you; I'm not involved in the industry but am a programming enthusiast. I've been at it for about two years now, but still consider myself a noob.

As for writing your first game, I suggest at this stage you stick to something simple that has been done before. Even something like solitaire!? That way you know the basic rules of the game and how it should work, and there is plenty out there to compare it to. Once you finish writing it, compare it to other similar games, and think about why (if at all) it is different, and how you can improve it. You will learn a bit through that process.

As for the 'starting point', I first write all my ideas down on paper, including horrible little sketches etc. Write down the core concepts of the game, i.e. how you want it to play. Once you know exactly what you want to program, then you can start worrying about how.

Following that, start thinking about what classes you will need to create, and how they will interact with eachother, and write it down. I also find that 'state diagrams' can really help with your design. Even if you don't physically draw state diagrams, visualise them in your head. Generally speaking, everything in your game will have a state including the game itself, and that state may change either from user input, or events within the game.

Once you've got all that business out of the way, start writing! Write a solid game loop, then go from there.

As Jimmt said, dive in and learn as you go. I've got lots of small projects on the go, none of which are very spectacular or complete, but most of them explore a particular concept that I wanted to learn and try out. I usually abandon them once I've learnt what I wanted to, but keep them for reference. I've finally got myself to a point where I feel competent enough to write a 'full' game.

Good luck and have fun.

17  Game Development / Game Play & Game Design / Re: Making 2D games creepy? on: 2013-03-06 06:16:46
Many people have previously posted on the visual and aural aspects of creating creepiness, but don't forget about the storyline. You can gradually weave it into the player's journey. For example, perhaps the player discovers diary entries as they go, chronicling the writer's descent into madness or evidence of horrible things that they have done. Maybe the player encounters NPC's who relay their experiences with the 'big bad things' in the environment, or who themselves are deranged and present the player with cryptic and 'freaky' dialogue.

As has already been mentioned, creepiness is often created through the inferred and unseen. A good supporting story & storytelling method can aid this, particularly in a 2d environment where it may be harder to immerse the player into the creepy atmosphere by visuals alone.

(Just realised this thread is a bit old... oh well!).
18  Game Development / Newbie & Debugging Questions / Re: Theoretical Solitaire Design Questions :) on: 2013-03-04 06:53:28
No problemos! Good to hear.  Smiley
19  Game Development / Newbie & Debugging Questions / Re: Theoretical Solitaire Design Questions :) on: 2013-03-02 06:41:45
Howdy,

It's not working because you treat the card as a JComponent, but you never actually add the card to a parent component. Hence even though you are drawing it, its not actually 'there' for click detection etc.

I'd also suggest that you don't do all that initialization within the main() method. That can all be moved to the Solitaire constructor.

Perhaps others would disagree with me, but I'm not too keen on your design here; using JComponents, having individual 'drag handlers' for each card etc. I'd use a single instance of a MouseInputListener, and handle everything from there.

Here's something I ripped up quickly, which is roughly how I would do the same thing:

Main Solitaire 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  
package solitaire;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*;

public class Solitaire implements MouseInputListener {
   
    ArrayList<Card> cards = new ArrayList<>();
   
    JFrame frame;
    SolitairePanel panel;
   
    int screenWidth = 800;
    int screenHeight = 600;
   
    //variables for card selection
   boolean cardSelected;
    Card selectedCard;
    Point lastPosition = new Point();
   
    Solitaire() {
       
        //Setting up the display
       frame = new JFrame();
        panel = new SolitairePanel(screenWidth, screenHeight, this);
        panel.addMouseListener(this);
        panel.addMouseMotionListener(this);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setResizable(false);
        frame.add(panel);
        frame.pack();
        frame.setVisible(true);
       
        //Adding some cards
       cards.add(new Card(50,50));
        cards.add(new Card(200, 200));
       
    }
   
    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {
        Solitaire solitaire = new Solitaire();
        solitaire.go();
    }
   
    public void go(){
       
        //Bad loop just for demonstration.
       while(true){
            frame.repaint();
            try {
                Thread.sleep(16);
            } catch (Exception ex) {
               
            }
        }
    }

    @Override
    public void mousePressed(MouseEvent me) {
       
        for(int x = 0; x < cards.size(); x++) {
            if(cards.get(x).bounds.contains(me.getPoint())) {
                this.cardSelected = true;
                selectedCard = cards.get(x);
                lastPosition.setLocation(me.getPoint());
                break;
            }
        }    
    }

    @Override
    public void mouseDragged(MouseEvent me) {

        if(cardSelected){
            selectedCard.move((int)(me.getX() - lastPosition.getX()), (int)(me.getY() - lastPosition.getY()));
        }
       
        lastPosition.setLocation(me.getPoint());
    }
   
     @Override
    public void mouseReleased(MouseEvent me) {
       
         //NOTE: you would probably check if the card move is valid here. If so, update game, stacks, bounds etc. If not, return card to original position.
        if(cardSelected) {
            selectedCard.updateBounds();
            cardSelected = false;
         }      
    }  
   
     
     //Following methods aren't used.
   
    @Override
    public void mouseClicked(MouseEvent me) {}
   
    @Override
    public void mouseMoved(MouseEvent me) {}
   
    @Override
    public void mouseEntered(MouseEvent me) {}

    @Override
    public void mouseExited(MouseEvent me) {}
}


SolitairePanel - for drawing etc.:
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  
package solitaire;

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

public class SolitairePanel extends JPanel {
   
    Solitaire game;
    int width;
    int height;
   
    SolitairePanel(int width, int height, Solitaire game) {
        this.game = game;  
        this.width = width;
        this.height = height;
        this.setPreferredSize(new Dimension(width, height));
    }
   
    @Override
    public void paint(Graphics g) {

        g.setColor(Color.black);
        g.fillRect(0, 0, width, height);
       
        for(int x = 0; x < game.cards.size(); x++) {
            game.cards.get(x).render(g);
        }
       
    }
}



Card 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  
package solitaire;

import java.awt.*;

public class Card {
   
    int width = 120;
    int height = 150;
   
    int xPos;
    int yPos;
   
    Rectangle bounds;
   
    Card(int xPos, int yPos) {
        this.xPos = xPos;
        this.yPos = yPos;
        bounds = new Rectangle(xPos, yPos, width, height);
    }
   
    //Move the card by setting the offset from its current position.
   public void move(int xOffset, int yOffset) {
       
        xPos += xOffset;
        yPos += yOffset;
       
    }
   
    //Update the bounds of the card, so that it can be selected.
   public void updateBounds() {
        bounds.setBounds(xPos, yPos, width, height);
    }
   
    public void render(Graphics g) {
        g.setColor(Color.red);
        g.fillRect(xPos, yPos, width, height);
        g.setColor(Color.blue);
        g.drawRect(xPos, yPos, width, height);
    }
}


Hope this helps!
20  Game Development / Newbie & Debugging Questions / Re: Theoretical Solitaire Design Questions :) on: 2013-03-01 09:52:04
I'd hold each card in a stack in an array. And for each card within the stack, calculate its 'visible/clickable extent', i.e. the top of the card poking out from within the stack, which could be stored as a Rectangle (this may be constant, or adjust dependant on the number of cards in the stack).

When you click on a stack, check which card's visible extent contains the click, by iterating through the cards in the stack array.

You could then use its array index to handle all cards above it. I.e. if a stack contains 13 cards, where stack.cards[0] is the card at the bottom of the stack, and stack.cards[12] is the topmost card, if your click detection determined you've clicked on stack.cards[8], then you apply the drag event to all cards from stack.cards[8] through to stack.cards[12].

21  Game Development / Game Mechanics / Re: Pixel based 2d destructible terrain? on: 2013-03-01 06:08:49
Cheers all.

I think that getting the pixel-array and editing it would be easier and faster than using setRGB

And this might be some help: http://www.mojang.com/notch/j4k2k6/miners4k/

That link is absolute gold Rorkien, thanks very much. Had to do some further reading on the pixel-array approach, but definitely sounds like the way to go. Calls to get/setRGB() appear to be relatively expensive. (This is new to me, I'm learning as I go!).

nerb.
22  Game Development / Game Mechanics / Re: Pixel based 2d destructible terrain? on: 2013-02-25 11:17:49
Quad tree is food for thought. At this stage I'm thinking of sticking to low-res maps. Although I guess there would be lots of contiguous empty areas or flat platforms. Using quadtree may reduce the need to inspect 60 or so pixels per 'lemming' per update. Although as you mentioned Damocles, it shouldn't take a big toll on modern hardware. Nonetheless, I intend to design it to run as lean as possible.

Cheers.
23  Game Development / Game Mechanics / Pixel based 2d destructible terrain? on: 2013-02-25 09:55:14
Hi  Smiley,

First off, I should say thankyou! Over the years I have often browsed JGO for answers to my questions or to fill in time, albeit have never signed up until now.

I'm toying with the idea of creating a lemmings-esque game, with pixel based destructible terrain. I've had a good googling and have some idea about how I will accomplish this. However I'd like to run my thoughts past the JGO community to see if I am on the right track, or if there is a better way.

Essentially I will use a foreground image that forms the terrain (plus a background image). This would likely be accompanied by a byte array holding destructability & collision information for each pixel.

Should pixels be destroyed (by explosions, digging etc.), then I will set the alpha byte of each affected pixel to 0x00 using BufferedImage.setRGB(), followed by updating the byte array, and then render the images.

Does this sound reasonable and efficient? Or would you guys go about this differently?

Thanks very much,
nerb.
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (107 views)
2013-05-17 21:29:12

alaslipknot (115 views)
2013-05-16 21:24:48

gouessej (144 views)
2013-05-16 00:53:38

gouessej (140 views)
2013-05-16 00:17:58

theagentd (152 views)
2013-05-15 15:01:13

theagentd (136 views)
2013-05-15 15:00:54

StreetDoggy (180 views)
2013-05-14 15:56:26

kutucuk (203 views)
2013-05-12 17:10:36

kutucuk (204 views)
2013-05-12 15:36:09

UnluckyDevil (210 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.406 seconds with 21 queries.