Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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: Android Bitmap on: 2014-10-21 19:10:49
Never worked with Bitmap, but my guess would be that the width of bmp is less than 11 + 22 = 33 as would be needed in the last line.

Edit: because it makes a subselection starting at x=11, of width=22, so you would end up at x=33 for the right edge of the selection.

Tyvm! I always did if it were positions on the bitmap itself, but they already do -start ._.''
2  Game Development / Newbie & Debugging Questions / Solved Android Bitmap on: 2014-10-21 18:54:54
I've a weird problem, which I don't know how to solve, as this website, doesn't give any information about it. So that is why I came here to ask you guys ^w^

Now my problem is that Bitmap is throwing an error in my face..

(Note: all the bmps are the same)
1  
bmpImage = Bitmap.createBitmap(bmp, 0, 0, 11, 11);

^This line works

1  
bmpImage = Bitmap.createBitmap(bmp, 0, 0, 22, 11);

^This line works

1  
bmpImage = Bitmap.createBitmap(bmp, 11, 0, 22, 11);

^This line throws an error:

1  
10-21 20:53:29.486: E/AndroidRuntime(27566): java.lang.IllegalArgumentException: x + width must be <= bitmap.width()


But the bitmap.getWidth() = 22 and the bitmap.getHeight() = 11 (as you can see from line 2, that is working..)
So basically I don't know what's really wrong about this line of code..

[Edit:] This topic should be in the android fora  Lips Sealed
3  Game Development / Newbie & Debugging Questions / Re: Orbital Mechanics / Velocity on: 2014-10-19 21:53:43
@ags1,
Well wow. How did I be so stupid, this will be alot easier! No algorithms mechanics needed just put them in a plain static path like the other entities. Thank you very much!

[EDIT]
Well it's solved now.  there is almost no CPU required this is all the code

1  
this.angleMagnification = -(Math.toRadians(360/(circumference/speed)));


1  
2  
3  
4  
5  
public void tick() {
   tick++;      
   this.x = (float) (orbiting.x + radius*Math.cos(angleMagnification*tick));
   this.y = (float) (orbiting.y + radius*Math.sin(angleMagnification*tick));
}


Thank you all very much and for your time spend. ♥
4  Game Development / Newbie & Debugging Questions / Re: Orbital Mechanics / Velocity on: 2014-10-19 18:31:21
I need to thank you all for your time, but I need to have a global picture of what I am dealing with.
The thing I want to accomplish is like a solar system with all the planets having a circular orbit (periapsis=apoapsis) and some moons having circular orbits around those planets. The only things I want to have a non 'static' path are comets. Could someone inventory the way how to accomplish this? like step by step a small procedure? I don't need any codes about it, just the procedure, or rather improve my procedure

Procedure
  • Every entity has a mass, starting position and the planet it is orbiting
  • Iterating all the entities and adds it change in position. This change in position is measured by the speed and the radius if the periapsis=apoapsis the radius is also the periapsis/apoapsis. Knowing this a circle around the sun(or planet it's orbiting) is Length = pi^2*radius. Having measured the length of the path you can get the angle by velocity/(length/360) = degrees. Having these degrees you can calculate the x and y that needs to be added.
  • Iterating comets?

Well as you still see I've some problems concerning comets and their calculations.. If there is anyone that knows the procedure to do that? The things I know now is that you need to calculate the vector of all the gravities together and then add velocity perpendicular to it. But I need a somewhat more specified procedure to do that..

[Edit]
It is also in 2 Dimensions, forgot to say that ..
5  Game Development / Newbie & Debugging Questions / Re: Orbital Mechanics / Velocity on: 2014-10-18 19:17:33
The only problem for that is that I need to work with vectors, and I believe Java hasn't a build in function for that so I need to design my own class. Having a bit of trouble with all the degrees, because if I am using tangets on a circle I will get some devided by 0 errors.. Also it's quite hard to figure out the degrees for the vectors, because of that...
6  Games Center / Android Showcase / Re: [Free] First Densetsu on: 2014-10-18 17:57:00
Graphics are reall good!
But what about the story? Does it even have a story I am interested!
7  Game Development / Newbie & Debugging Questions / Re: Orbital Mechanics / Velocity on: 2014-10-18 17:42:09
The moon have a speed in a direction, that is the vector Velocity.
Then you have the gravity, thats a vector from the moon to the center of the planet.

Each frame/update you calculate the gravity vector (moon center to planet center, normalized, plus gravity strength) and then add it to the velocity vector.

To start the simulation: set the position of the planet and then the position of the moon. Calculate the gravity vector and make the velocity be perpendicular to it.

Now for the moon to orbit you must find the equilibrium between moon speed and planet gravity.

If the speed is too high or the gravity too low, the moon will fly away. If the moon is too slow or the gravity too strong, the objects will collide.



+1
Is there also a calculation for the velocity in a circulair orbit?
And if I have like a moon that is orbiting a planet which is orbiting the sun, should I take both of their gravity vectors and then add the velocity vector perpendicular to it? So basically after smashing all the gravity vectors I add the velocity vector, but if I want to do that I should know a way to calculate the velocity. Any idea how I should accomplish that?
8  Game Development / Newbie & Debugging Questions / Re: Orbital Mechanics / Velocity on: 2014-10-18 17:13:48
V = sqrt(GM/r)  , off google where V = velocity required to sustain orbit G is gravitational constant, M is the mass of the central object , and R is the radius from the center of the orbit. you can recalculate R each time . meaning say velocity is too low them recalculate when R is , then reinput R into the equation to obtain the new value.

But how do I know in which direction this vector goes? Or just 90 degrees compared with the AccMagnitude?
9  Game Development / Newbie & Debugging Questions / [SOLVED] Orbital Mechanics / Velocity on: 2014-10-18 16:28:00
Greetings,
Currently working on Oribital Mechanics. The only problem I don't know how to solve after investigating alot of time is the fact that the object in space is pulled straight down to the planet/sun.. B

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
for (int i = 0; i < entities.size(); i++){ //go through all the planets
         if(entities.get(i) != sun){
            double distance = 0;
            for (int j = 0; j < entities.size(); j++){ //add up the gravitational effects of all the other planets
                 if (i != j){
                    distance = Math.sqrt(Math.pow((entities.get(i).getX() - entities.get(j).getX()), 2) + Math.pow((entities.get(i).getY() - entities.get(j).getY()), 2));
                    double G = 60000;
                    double accMag = (G*entities.get(j).getMass())/(Math.pow(distance, 2));
                    double accX = (accMag*(entities.get(j).getX() - entities.get(i).getX()))/distance;
                    double accY = (accMag*(entities.get(j).getY() - entities.get(i).getY()))/distance;
                    entities.get(i).addVX(accX);
                    entities.get(i).addVY(accY);
                 }
            }
              entities.get(i).updatePosition();
         }
      }


Click to Play

This said, means that I only got the accMagnitude and I don't know how I get the velocity. Also I know I probably should be using vectors to calculate it's path. So my question is how I can calculate the velocity. I am probably overlooking some things right now..

As always, thank you very much
-Roseslayer
10  Game Development / Newbie & Debugging Questions / Re: Double becomes infinity on: 2014-09-30 12:23:44
Step backward: Math.exp(x) = e^x.  you want x*x.

exp of zero is one.

yes, I want x^2. stupid of me ...
11  Game Development / Newbie & Debugging Questions / [SOLVED] Double becomes infinity on: 2014-09-30 12:13:16
Greetings,

I don't know what to do to solve this. If anyone know what's the problem, tell it to me in words. I am not learning if someone is pasting codes ^w^!
Tick
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
for (int i = 0; i < entities.size(); i++){
         if(entities.get(i) != sun){
            for (int j = 0; j < entities.size(); j++){
                 if (i != j){
                    double dist = Math.sqrt(Math.exp(entities.get(i).getX() - entities.get(j).getX()) + Math.exp(entities.get(i).getY() - entities.get(j).getY()));
                    double accMag = entities.get(j).getMass()/(Math.exp(dist));
                    double accX = accMag*(entities.get(j).getX() - entities.get(j).getY())/dist;
                    double accY = accMag*(entities.get(j).getY() - entities.get(j).getY())/dist;
                    entities.get(i).addVX(accX);
                    entities.get(i).addVY(accY);
                    System.out.println("dist: " + dist + ", accMag: " + accMag + ", accX: " + accX + ", accY: " + accY);
                 }
            }
              entities.get(i).updatePosition();  
              System.out.println("New postition of Planet [x=" + entities.get(i).getX() + ", y=" + entities.get(i).getY() + "]");
         }
      }


System.out.println()
1  
2  
dist: Infinity, accMag: 0.0, accX: 0.0, accY: 0.0
New postition of Kerbin [x=80000.0, y=0.0]


Well the problem is basically as you can see, that  dist is becomming Infinity, and because of this, the other variables are 0

-RoseSlayer
12  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?
13  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?
14  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[]?
15  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.
16  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
17  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
18  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
19  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
20  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
21  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
22  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
23  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?

24  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
25  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
26  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
27  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

28  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.
29  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.
30  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
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.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (42 views)
2014-10-16 15:22:06

Norakomi (32 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!