Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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] 2 3 4
1  Game Development / Newbie & Debugging Questions / Re: Different stats on the same Array? on: 2014-01-08 15:18:06
So just make for every item a new class? But for the normal items like for example a leaf, without any customizable id's should I also make a new class?
2  Game Development / Newbie & Debugging Questions / Re: Different stats on the same Array? on: 2014-01-05 13:28:45
So basically I need to make a new instance of them and increase the ID everytime I add another sword?
3  Game Development / Newbie & Debugging Questions / Re: Different stats on the same Array? on: 2014-01-04 19:30:08
How did minecraft solved this problem? If changing the name of a sword the don't add another pointer to the Items[]?
4  Game Development / Newbie & Debugging Questions / Re: Different stats on the same Array? on: 2014-01-03 16:25:46
Are your fields for the attack damage etc. static? You'll want to make them instance variables, otherwise the stats will be shared between every instance of the item.

They aren't static, they are protected. All the variables are protected.
5  Game Development / Newbie & Debugging Questions / Different stats on the same Array? on: 2014-01-03 15:55:41
Hi there JGO,

first of all: happy new year! I've an array[] with all the items saved in them. If I change 1 stat of the array all the items with the same id will be changed aswell. So is there a way on having different stats in an Array[]? Please only tell me how to, I want to programm it myself!

Code:
1  
2  
3  
   public static final Items[] tiles = new Items[400];
   
   public static final Items SWORD = new ToolsSword(10, 12); //for example these stats are AttackDamage and AttackSpeed


With this code all the items (with the same id) will have the same AttackDamage and ASpeed. So what is the best way to be able to change the attackDamage without changing them all?

if you use something like this:
1  
2  
3  
Void changeAttackDamage(int attackDamage){
this.attackDamage = attackDamage;
}

then it will change the damage of all the items (with the same id).

If you don't understood the question, just say it.
Thanks for helping already!
-RoseSlayer
6  Game Development / Newbie & Debugging Questions / Re: Inventory, how to make cells 'bigger'. on: 2013-12-10 14:44:40
I personally think it would look very weird with the line still there because it just doesn't fit in the spot. The other thing you could do is create a miniature version of the texture and just use that instead. I think that would work better mechanics wise.

What do you mean with the miniature version, the items that you can see in the inventory are already size *2
& thank you for the +1  Cool

-RoseSlayer
7  Game Development / Newbie & Debugging Questions / Re: Inventory, how to make cells 'bigger'. on: 2013-12-09 20:59:33
Thanks for the help, as always!

This is the finished product:



-RoseSlayer
8  Game Development / Newbie & Debugging Questions / Re: Inventory, how to make cells 'bigger'. on: 2013-12-09 15:24:23
Thanks, going to work on it!
-RoseSlayer
9  Game Development / Newbie & Debugging Questions / Re: Inventory, how to make cells 'bigger'. on: 2013-12-09 14:41:18
So basically you want to make some "cells" bigger than the rest? I kinda don't really understand what you want to achieve. You want to keep some cells at size x, and make some others of size 2x ?

I don't want to make the cells bigger, but the items in the cell are bigger then the cell, so it needs to look like the cells has become bigger example:



As you can see here, some items are bigger then 1 cell.

-RoseSlayer
10  Game Development / Newbie & Debugging Questions / Inventory, how to make cells 'bigger'. on: 2013-12-09 14:26:29
Hi there JGO,

currently I am working on the Inventory. I had an idea to make some items bigger then 1 cell:



But if you can see it is only rendering a bit of the item. I had some ideas to make a few variables, and then just try things out. But it doesn't seem to work that good. The only part that was good is the selection of multiple Cells:

1  
2  
3  
4  
5  
6  
7  
8  
9  
   public List<Integer> biggerCell() {
      List<Integer> cells = new ArrayList<>();
      for(int x = 0 ; x < item[0].getWidth(); x++){
         for(int y = 0 ; y < item[0].getHeight(); y++){
            cells.add(this.x + x + (this.y + y) * maxWidth);
         }
      }
      return cells;
   }


So my question is: Are there any tutorials on how to make cells that are 'bigger' than 1 cell?
Or if you have any ideas, just post them and I will do something with it! (Please do not post any codes, I am still learning and it is not learning if I am copying stuff).

Thanks already!
-RoseSlayer
11  Game Development / Newbie & Debugging Questions / Re: Circle hitboxes. on: 2013-12-06 22:57:44
Screenshot I mean Tongue

But code would be nice too, if you so desire.

I don't have a for-loop so you cannot see the circle, I dont think I got time for making like random points around the character and draw the circle, currently working on items and armor:



Thanks for showing interest ^,^
-RoseSlayer
12  Game Development / Newbie & Debugging Questions / Re: Circle hitboxes. on: 2013-12-06 22:32:52
Can I see a pic of the new product? Tongue

Which product do you mean, the code or a screenshot of the game?

13  Game Development / Newbie & Debugging Questions / Re: Circle hitboxes. on: 2013-12-06 20:09:48
I've just found a possible answer,

Use Pythagoras' theorem!  A2 plus B2 = C2!

Have the point you are checking for check for the distance of x for 'A' and distance of y for 'B'. if the square root of 'C2'(also known as C) is less than or equal to the radius you are checking for, then the boundary has been reached! Cheesy

Haven't actually tried this out, but I hope I've helped.

! THANKS, Now it is a real circle, not a rotate Square! Cheesy
Thanks for all the help guys, love the JGO!
-RoseSlayer
14  Game Development / Newbie & Debugging Questions / Re: Circle hitboxes. on: 2013-12-06 20:05:34
It was stupid of me to make a hitbox for combat, it will take alot of cpu to do a forloop or algorithm the whole time, a simple code to calculate the pixels between the entities is much better:




These 2 pictures will show it is now a circle! (or is it a 45° turned square? Tongue)

-RoseSlayer
15  Game Development / Newbie & Debugging Questions / Re: Circle hitboxes. on: 2013-12-06 19:51:53
Why is your hitbox so big?

Its silly to have to change your collision algorithms just because you for some reason don't have a smaller hitbox. Just use an AABB and check against the tiles, which will also have hitboxes.

The other way you could do it is just to check if the tiles around the player are "solid", and if they aren't you can move. I don't recommend this way, however, because you can only check tiles, and the tiles will have to a uniform size with every other one. So you won't be able to have half tiles or special items with hitboxes. Just use AABBs, which by the way do not require for loops for anything.

As a side question, is your game based off of vanZebans game?

I even don't think I need a hitbox anymore, I could make a check like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   public boolean inRange(){
      int xDifference = entityTarget.x - x;
      int yDifference = entityTarget.y - y;
      if(xDifference < 0)
         xDifference = -xDifference;
      if(yDifference <0)
         yDifference = -yDifference;
      if(xDifference + (yDifference - 3) <= range)
         return true;
      return false;
   }
}


It was a hitbox for combat, not for walking.
and your side question is true. (wich is kinda obvious didn't changed character image Tongue).
-RoseSlayer
16  Game Development / Newbie & Debugging Questions / Circle hitboxes. on: 2013-12-06 19:40:31
Hi there JGO!

I've plans for the combat-system, but I only need to have some sort of range to continue. I thought I would make a simple square hitbox, with 4 forloops:



But as you probably can see is that the side of the square are closer to the center then the edges. So if anyone know a way to make a circle hitbox, it would be great.
I thought something of: x+y = range (20) and then looping through a forloop of them. I only have no idea how I am going to accomplish this. So I need your help, if you help me don't post any code, as I need to learn from experiencing with my own ideas.

Thanks already!
-RoseSlayer

17  Game Development / Newbie & Debugging Questions / Re: Saving an array on: 2013-12-01 19:14:53
First off, they aren't scripts. Sorry, but it bugs me when people call code scripts.

Second, as you're making a voxel game and I've dabbled in it(I have a YouTube series I never finished), I can say you shouldn't store the actual tiles in an array, save the id of the tiles (generally a byte).

Third, your code isn't a bunch of Java functions, so saying it doesn't work is the least helpful thing you can do. Make sure you allow your chunks to be serializable as well as the tile class (I believe). Post your generateChunk method, show us what you do with the array you load from the file. A helpful thing to do would be to loop through the array and print out every object to see if the file is saving/loading correctly.

Sorry for using the word "scripts" in the wrong way... Saving the id in a bite is actually a very smart idea! easy and works great. If i am using bytes I also don't need all the other variables so it will also be very good for the CPU. Thank you very much for this! When I post a topic next time I'll keep it in mind to do what you said! So thank you again!

-RoseSlayer.
18  Game Development / Newbie & Debugging Questions / Saving an array on: 2013-12-01 18:25:58
Hi JGO,

I am getting errors everytime I am opening a new chunk, but when I am fixing other problems it gets kinda annoying.. So I wanted to fix this problem, but I don't know if there is a way to save a LevelTile[][]...

Currently my saving and loading scripts are:
Saving:
1  
save.writeObject(this.tiles);


Loading:
1  
this.tiles = (LevelTile[][]) load.readObject();


And the whole code (if you want to see this for some reason):
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  
    public void saveChunk(){
      try {
         File file = new File(levelDirectory + "/chunks/chunk[" + x + "," + y + "].dat");
         if(file.exists()){
            file.delete();
         }
         FileOutputStream saveFile = new FileOutputStream(levelDirectory + "/chunks/chunk[" + x + "," + y + "].dat");
         ObjectOutputStream save = new ObjectOutputStream(saveFile);
         save.writeObject(this.tiles);
         save.close();
      } catch (Exception e) {
         e.printStackTrace();
      }
    }
   
    public void loadChunk(){
      try {
         File file = new File(levelDirectory + "/chunks/chunk[" + x + "," + y + "].dat");
         if(file.exists()){
            FileInputStream loadFile = new FileInputStream(levelDirectory + "/chunks/chunk[" + x + "," + y + "].dat");
            ObjectInputStream load = new ObjectInputStream(loadFile);
            this.tiles = (LevelTile[][]) load.readObject();
            System.out.println("CHUNK LOADED");
            load.close();
         } else {
            generateChunk();
            System.out.println("CHUNK GENERATED");
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
    }


If you've any questions, please ask!
Thanks already!
-RoseSlayer.
19  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-07 08:45:10
@Icass, thank you very much! And all the others that've been helping me to fix this problem. So it was a border problem
20  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-06 14:49:15
Where is you draw code?
Just to test it, make sure you scale all your tiles:

1  
g.draw(tile, x, y, SCALE_W, SCALE_H, null)


all the colours from the render script are made into 1 single image, and then it is drawn:

1  
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);   
21  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-06 13:42:49
I know a tutorial very similar with your game. Maybe if you check how it is made, you find what you have wrong.

DesignsbyZephyr tutorial

That is this game, only I took it a step further. He also has the render glitch but he probably doesn't saw it
22  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-06 08:50:12
How big is your original image, before any scaling? Never mind.

All I can think of is a rounding error somewhere with your ints.

EDIT: Actually, I don't even see it. And I couldn't check the actual width in Paint.NET, because the image is scaled. Sad

All the scales are most times 1, except text. I think it might be a graphical error that the 1 pixel is just missing and there is nothing rendered on it.. Or something.. But it keeps getting more and more annoying as I want to progress with my game :/
23  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-06 07:35:10
If you upgrade a 4-pixel wide image to 9-pixels wide, one of those pixels will be scaled to 3 times normal while the rest are only 2 times.

Of course this may not be your problem, but that's all I can guess from the information I have.

This is exactly the problem the 4pixels wide pixel is sometimes scaled to 5pixels, But I can't seem to find where the code is wrong :/
24  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-06 07:06:59
Thats because your image has a border. When you render two images next to each other, it will look like your each slot has an extra pixel.

try drawing your border with lines instead of using images with lines in them already

This graphical glitch only happends at certain coords on the screen. It are always the same coords. And because I think the images are moving constantly, that there is nothing wrong with the border. Still Thanks for trying to help!

Without analyzing your code, I had a similar problem with a game for android that I made.
I was converting my position from double to integer to draw my images.
Example:
If you add 32.5 pixels each loop and you start at 0:
0 + 32.5 = 32
32.5 + 32.5 = 65

but 32 + 32 = 64... you have 1 extra pixel there.

The problem is I am not using any doubles except from my movingspeed.. But still thanks for trying to help me!
25  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-11-05 19:43:27
Still the same problem and I can't seem to find the problem... It is getting really annoying when I am trying to add buttons some positions are wrong drawed :/.. Does anyone have an idea?
26  Game Development / Newbie & Debugging Questions / Re: Biomes and their generation within? on: 2013-10-11 14:37:32
5. generate temperature and rainfall

I made a perlin Noise to generate the temperature and rainfall, but there is a low chance it reaches 100%, my  code for perlin Noise is:
1  
2  
int temperatureNoise = (int)(noises.get(1).noise(x/(biomelength*3), y/(biomelength*3)) * 100) + 50;
int rainfallNoise = (int)(noises.get(2).noise(x/(biomelength*3), y/(biomelength*3)) * 100) + 50;


What is a better way to make a biome better (And I want to have a feature where u can change to times u will come across this biome. Lets say: I want 20% chance to get a desert and 1% to get a swamp. Is there a good way I can implement this in the rainfall and temperature generator?
27  Game Development / Newbie & Debugging Questions / Re: Biomes and their generation within? on: 2013-10-02 14:59:39
Just generate a few points around the center of the "lake". You could use the radius to generate a smooth lake shore, or you could you use radius and a random number to add/subtract to the radius to generate rough shores. Personally, I would create a temporary list of these point and assign an idea according to when they were generated, so like "p1, p2" etc... So then you could just use the Pythagorean theorem and connect the point in order. "p1" to "p2"... Then delete the points and fill in the lake by using two for loops for the x and z axis. The water should then fall and fill the z axis. That's how I would do it, I don't know if it wouldn't work for you however.

Great idea, I will implement some pieces of this, probably I am now going to make somesort of this...

In my generators I often use rule "fill everything around selected point if altitude of this points is lower than the starting one".

The only problem in my generation script is that the flat land is always on the side of a hill.. So evrything will flood entirely if I am making a lake on the top of a mountain? the height is always "climbing".. (still using Perlin Noise, because I am lazy Tongue)

-RoseSlayer
28  Game Development / Newbie & Debugging Questions / Re: Biomes and their generation within? on: 2013-10-02 13:28:46
My way of generation of 2d map:

3. generate lakes (check random points, "fill" them with water, if lake is big enough and not too big apply changes to map)

How is it possible to generate lakes? I can generate a single point good, but how can I make multiple points? They are also made "on the fly", so I can't edit them because that will give an error if I try to edit a tile with a higher x, y... and because I am making them "on the fly", I can't generate with: generation = new Random(this.seed);, because if I visit other chunks first, they have the generation.nextInt(1000)  <= 1.. So it will only work If I walk 1 direction. :/ any suggestions? generation = new Random(this.seed + x*16 + y*16) works fine..

-RoseSlayer
29  Game Development / Newbie & Debugging Questions / Re: Biomes and their generation within? on: 2013-10-01 15:28:41
My way of generation of 2d map:

1. generate heightmap using simplex noise
2. place basic, height-based biomes (sea, mountains and null - the last one for all future biomes)
3. generate lakes (check random points, "fill" them with water, if lake is big enough and not too big apply changes to map)
4. generate rivers (check random points, use A* alghoritm without end point - first reached tile with sea/lake will generate river - use height as heuristics)
5. generate temperature and rainfall
6. generate another biomes to replace null biome

A* can generate really good rivers very fast. Smiley

Oops, forgot to say that it was 2d. Thanks for the answer It really help me (and maybe others that are using the searchbar on JGO). Thanks for helping me. I know what to do and now can do some work again!~

-RoseSlayer
30  Game Development / Newbie & Debugging Questions / Biomes and their generation within? on: 2013-10-01 15:14:17
Well hello there, JGO!

This month I am doing stuff and experimenting on level generation. I am currently using Perlin Noise as generation for the landscape and it just looks like Perlin Noise (obviously).. So I am searching all about a biomes on the internet. On JGO there are no "good" posts about Biomes and generation, you are only able to find to-do lists like:

Quote
To-Do list:
-Biomes added.

So I started to search on google, but every topic about Biomes are modding-topics for MineCraft... After some time I found some good posts: How do MineCraft biomes work? and Voronoi diagram.

But the first link is more like how to do it right without a tutorial on how to do it.
And the second link is about the Voronoi Diagram. I can't see, how I can generate rivers (small/streched) and oceans (big/not streched). Because If you use this methode you can only make biomes from the same length?

So my question is: What would be a good methode for Biomes (and their generation in the biomes)?
As you can see my English isn't that good, so I do not understand the Voronoi Diagram fully.

I already thank you for reading this post!
-RoseSlayer
Pages: [1] 2 3 4
 

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

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (35 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
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!