Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 ... 10
1  Discussions / General Discussions / Re: This is one of the worst feelings i ever had on: 2014-06-17 13:55:03
==> Visiting this may put you in dangers Vs no it wont

<a href="http://www.youtube.com/v/moSFlvxnbgk?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/moSFlvxnbgk?version=3&amp;hl=en_US&amp;start=</a>



Maybe the solution for the privacy issue is not a technical one (like Tor) but a political and legal one: we need a government that strikes a good balance between respecting and protecting privacy, and limiting privacy where it is needed.

but then  there is  :
Quote
Since OP had no trouble finding the material in question it's highly likely that some policing authority is aware of it's existence.

My guess is that "the powerful" are aware of everything there (that is for sure) but i believe that they have all the means to stop these things from happening but they don't cause they want to give their enemies the illusion of being 100% protected and stop them when they need to, i really don't believe that this "Tor project" is made by "the people".   
2  Discussions / General Discussions / Re: This is one of the worst feelings i ever had on: 2014-06-16 21:41:33
==> to all the replies about me can get in troubles because of these things, thank you but it can't happened, like it literally can't, beside that my country doesn't have any strict internet law (we don't have terrorist attacks like in Iraq, Syria or Afghanistan, but when these extremist attacks, they share their plan of facebook during the event lol ) i am 100% sure that none of these content is in my hard disk now, but i'll keep in mind to not take this laptop with me when i leave the country, no one knows what could happens  Tongue
again, thank you for your concern but this isn't the subject of this thread.

Quote
I agree, the lack of a serious response can be pretty upsetting on its own.....A couple other historical examples: slavery, pedophilia in the Church, a culture/mindset that blames women when they are raped...
+1!! specially for the last example, last year in my country, two police officers raped a girl who was hanging out with her boyfriend late at night (they were in a club) the two officers handcuffed the guy and raped the girl, do you know what happened at first ?
the couple was accused by being in a "wrong situation" (they were kissing or whatever) and since this is a "Muslim" country (not anymore with the new constitution  Grin ) the couple has to spent 6 months in jail, while the officers crimes was ignored but hopefully and thanx to the right media coverage the case has been changed completely, the couples are out and the 2 officers are going to spent a good time in prison together
Quote
"choking" or "shocking"?

lol shocking*

Quote
My question though is, having known your extreme distaste for this kind of stuff; why did you go looking for such things on the internet? :/

i mentioned above that people always start to imagine all sort of stuff when it comes to things that no one can prove if these are true or false, just like religions or myths and i am 100% sure that if i give you even a little hope that with an "x-thing" you can discover if this religion or myth is correct or not then you will definitely use it and hope that what you have in mind doesn't change, that's why i did it, i was hoping that this guy is just exaggerating like everyone else, so in the start (during the search) i the worst case that i was expecting is to find a forum to sell guns, but by coincidence (i don't want to give full details) in a Reddit post that is supposed to solve a pure technical problem, some guy just posted a link to the hidden wiki and since you are studying psychiatry, you know that humans are too curious to walk back in such situations, like really imagine yourself in my place, you are so confident and sure about something and suddenly you find stuff that claims to prove the direct opposite and the only thing between you and certainty is a single click, what do you do ?  
3  Discussions / General Discussions / Re: This is one of the worst feelings i ever had on: 2014-06-16 13:47:15
Quote
This stuff comes from all over the world though, very different people and groups. Who to attack?
I think that if each country try to give this problem some attention then things can get better, cause that is the main problem, i really NEVER heard about anyone talking about the dangers of these websites before. Some idiots in the U.S (i read about others in France too) these are doing their best to prove that video games are a real danger for "your" kids but no one is even trying to move about this problem ? that's "weird"

Quote
I have no idea what the situation is in Tunisia.

I would take Riven's advice seriously.

I appreciate Riven's advice and yours too, but as i mentioned before, according to the law (our law) i didn't commit any crime, i don't posses these things (posses in the real meaning of it, not just a browser cache) am also not "commercializing" these things nor enjoying watching them.

Quote
Resolving your own problems, by yourself, is the way to improve yourself imo  Pointing
Of course there's a limit to that, but you know your own morals best. There's messed up stuff all over the world, what you can do is not let it affect you being the best you can  Smiley

How can i explain this  Tongue
The problem is that i was always thinking that such things doesn't exist, not by this amount at least, i always thought that men worst behavior can happens only during wars, which somehow i believe that there is a reason to do anything, good reason or bad reason, that depends on the angle you are looking from, but this, is BAD and there is no reason to explain it, and it literally got into my mind from no where, it's very chocking, i can't find a stronger word to explain it.

@Rayvolution & @philfrei
maybe i don't need a therapist but i surely need someone to talk with about these things, and when i did, the first thing i noticed is that people doesn't react seriously to the problem, some even laughed, some others start to run to their religions assuming that this things happens cause these people doesn't have religion (sometimes i want to punch them right in the brain  Emo ) and others start to talk about all sort of things, from "some humans are just bad" to "Illuminati  Cool " (i have no idea why lol)
that's why i started this topic here, now for the therapy, am the kind of people who lose conscious when i saw other people in real harm, i'll explain, for example if i watch the ultimate gore movie, then nothing will happens to me at all, but hear this [true story] once i was in the bus with 2 friends, one of them was talking about a guy who had a car accident and he start describing the effect that event does to his face.... i woke up with more than 10 people looking at me and putting all sort of perfume under my nose lol
bottom of the line, the images that i saw are very very very disturbing for someone like me, and if they doesn't go away, i will think about consulting a therapist.

thank you all.
4  Discussions / General Discussions / Re: This is one of the worst feelings i ever had on: 2014-06-16 03:48:42
Quote
No, you don't.  Wink
i hope so.

Quote
Correct.

The world doesn't seem to work the way you think it does, you can't just say "we have supercomputers, so why isnt this problem solved?!!!" those are 2 completely different issues.

I get your meaning, but i think you didn't got mine, am not saying that because we have super computers then automatically we are able or we have to solve this problem, what am saying is that we dedicated ourselves to solve problems way more complex than this and it ended up with an epic success, while in this problem everyone think that the best thing to do is to just ignore, and i think that this is because 99% of the people doesn't know that such thing existed and even if they did, they just build their own ideas about it cause they never saw how cruel and dark it is, Am very sure that with the right media coverage this thing can be killed.


 
5  Discussions / General Discussions / Re: This is one of the worst feelings i ever had on: 2014-06-16 03:25:01
Quote
Still curious what you are taking about.

about this
Quote
The extreme videos (like the pedo and murder videos) are more up to the actual police force to track down
unfortunately i've seen a very extreme video and couldn't even finish it, but the worst thing is that i saw the source of it, a forum with thousands of posts that probably each post contain things similar or worst than this. I always thought that this kind of things are very very rare, to the point that i only heard about it in movies, TvShows or in the worst case, in wikipedia while reading a page about some psycho serial killer, but the fact that this things exist by this amount is very terrifying, seeing the images is disgusting by all meaning of this word, but realizing that there is a lot more is very hard to accept.

Quote
I am about my  mental health. Even though I have probably seen it all - don't need to see it again
I know what you mean, and actually i think that i may need a therapist.



Quote
What did you expect?
   
Quote
It can get complicated to eradicate such things because it depends where the server is, who owns it, and so on. Best just to ignore it IMO.

Please do not be offended guys, but, you are kidding right ? you want to tell me that we are able to create computers that make millions of calculations per second, space stations, advanced vehicles and weapons, medicals and drugs, extremely complicated architectures, and more and more, but it is impossible to put all this motherf**kers in jail  Stare ?

 
 
6  Discussions / General Discussions / Re: This is one of the worst feelings i ever had on: 2014-06-16 00:19:06
Quote
Looking at these materials and possessing them is actually a crime, which you just admitted to commit.

it depends on what you mean by "looking", i think the law is talking about the intention to look at these materials and not the fact of just looking, and the same goes for possessing.
I didn't search for any of these, in fact, i found everything on Reddit, and i was like "wtf Shocked ??", some post there, that is meant to solve a technical problem using some sort of proxy, in that post a guy/or girl posted a link to what is called the hidden wiki and the titles there were too bad to ignore....
PS:
i didn't spend more than 10 minutes (including the time i lost conscious  Tongue )

Quote
Best bet is to just not look for it if you don't want to see it
but what about all these kids  Sad ?
pfff... this is really messed up....

Quote
by now, like 20 years after the fact, due to snowden finally its out in the opening whats going on with the NSA...
i never was 100% against the NSA, in one condition, they have to protect everyone, not only their interests, but it seems that the only solution is to bring Harold Finch and his machine to life... 

Quote
Why would they help ? Looking at it purely logical and without morals. If it benefits you and you can look like a hero on the way, sure, but why if there is not reason too.

you know, i never was a religion guy, but sometimes, i wish that all religions are true and that one day these sick people will enjoy the most painful pain of all time in Hell.

[mad world]
7  Discussions / General Discussions / This is one of the worst feelings i ever had on: 2014-06-15 20:20:49
Hello JGO,

I have no idea if this subject has been discussed here before and neither if we are allowed to talk about it here or not, but am going  to start this topic anyway and i hope i got some wise answers, as always.

2 days ago some of my friends initiated a discussion about the deep web, and just like every time this subject is brought, people tend to start using their imagination a little bit more than usual, since it's something that is supposed to be invisible then you can start claiming any sort of things and just say that the others are not good enough to find it, however, this time i was discussing it with someone that i don't think he tend to act like that, and he told me that he found things that i REALLY thought that they existed on Hollywood movies or some CriminelMinds-Like TvShow. So i decided to make a little dive in what's called the deep web, and i wish i didn't....

[snip]

The question is, why does this shit exist Huh and am not talking about the sick people who are doing it, no these are sick and they will always continue to exist, am talking about those who have the power,  FBI, NSA, CIA, Interpol, the coon, anyone??
is it really that hard to shut this f**kers down ?? they are using the internet right ? and they need internet providers right ? so there is surely a way to track them down or at least shut down these websites, no ?   am not a big fan of the conspiracy theory, but, they are not ignoring and/or supporting this right ?

Thank you.
8  Game Development / Newbie & Debugging Questions / Re: [libGdx]rotating group element cause rectangle misplacement on: 2014-06-11 18:17:44
I know it's not what are you asking but, why don't you use circle collisions instead of rectangles?

because i want to know why the rectangle are acting like this, i am 100% sure that am missing a very simple thing, there is a gap between positioning the graphics of the actor and the collision rectangles, and am waiting for someone with enough experience to tell me what am messing  Roll Eyes 
9  Game Development / Newbie & Debugging Questions / Re: [libGdx]rotating group element cause rectangle misplacement on: 2014-06-11 15:11:40
I don't really see what is your problem. Is the problem that your group is being rotated around bottom-left corner? Well, you just have to change pivot/center point of the group to rotate it's children around.

Finally  Grin !! someone has decided to interfere!!
Thnx a lot man!!!

And nope, that is not the problem. if you have a couple of minutes to read this blog post of mine then you will understand exactly what am willing to do.
but let me re-explain again  Smiley

say that i have a group named G, this group contain 3 objects A, B and C
the goal is to rotate both 3 objects of the group as they are a single object, basically they are all rotating around the group pivot no matter where they are in space, and if you have visited the link above, the Group feature of Scene2D has completely solved my problem.
BUT for some strange reason, i cannot find a way to have a rectangles for collision, remember the A,B and C object ?
i want each one of them to have Ar, Br and Cr (r for rectangle) that behave exactly like A, B and C, i simply need rectangles around these objects to check for collision.

i've been searching a lot to solve this problem, and am still out of luck, am actually starting to thing to drop the Group approach and use Box2D and one of it's grouping features ? (joints or whatever)

thank you again and have a great day
10  Game Development / Newbie & Debugging Questions / Re: [libGdx]rotating group element cause rectangle misplacement on: 2014-06-11 02:37:15
up please
11  Game Development / Newbie & Debugging Questions / Re: [libGdx] rotating group element cause rectangle misplacement on: 2014-06-08 23:08:28
okay so i made some progress and the problem seems to appear only when am rotating the group, but when am moving it in the X or Y then everything works fine, to give you more insight, here is a GIF that represent the issue
 

and here is how am doing it

this is method is to setup the stage, group  and actor :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
private void createThePaddle() {
      // Create a stage
     stage = new Stage(new StretchViewport(game.WIDTH, game.HEIGHT));

      // Create a group and add it to the stage.
     group = new Group();
      stage.addActor(group);

     
      Sprite sprite = new Sprite(circleImg);
      // this is what the paddle class take (i'll post it below)
     redPad = new Paddle(redCol, "red", sprite, new Vector2(0, 0), 1f);
      // adding the actor
     group.addActor(redPad);
      // setting the position relative to the stage
     redPad.setPosition(0, 0);
      // setting the group position in the middle of the screen
     group.setPosition(RgbX.WIDTH / 2, game.HEIGHT / 2);
   }


this method is to update the group :
(if i enable the commented part and disable the rotation everything works fine)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
private void groupUpdate() {
      if (Gdx.input.isKeyPressed(Keys.LEFT)) {
         group.rotateBy(rotSpeed);
         //group.setX(group.getX() - 100 * Gdx.graphics.getDeltaTime());
     }
      if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
         group.rotateBy(-rotSpeed);
         //group.setX(group.getX() + 100 * Gdx.graphics.getDeltaTime());
     }
      if (Gdx.input.isKeyPressed(Keys.UP)) {
         //group.setY(group.getY() + 100 * Gdx.graphics.getDeltaTime());
     }
      if (Gdx.input.isKeyPressed(Keys.DOWN)) {
         //group.setY(group.getY() - 100 * Gdx.graphics.getDeltaTime());
     }
   }


and this is the render method :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
@Override
   public void render(float delta) {
      // TODO Auto-generated method stub
     Gdx.gl.glClearColor(0, 0.0f, 0.0f, 0);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

      groupUpdate();

      stage.act(Gdx.graphics.getDeltaTime());
      stage.draw();

      Vector2 pos = redPad.localToStageCoordinates(new Vector2(0, 0));

      float[] poly = rectangleToVertices(pos.x, pos.y,
            redPad.sprite.getWidth(), redPad.sprite.getHeight());
     
     
      shape.setProjectionMatrix(stage.getCamera().combined);// this doesn't make any difference
     shape.begin(ShapeType.Line);
      shape.polygon(poly);
      shape.end();

     
   }


and finally this is the Paddle 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  
package com.aladine.rgbx;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;

public class Paddle extends Actor {

   public Color color;
   public String type;
   public Vector2 position;
   public Sprite sprite;
   public float scale;
   public Rectangle rectangle;

   public Paddle(Color color, String type, Sprite sprite, Vector2 position,
         float scale) {

      this.color = color;
      this.type = type;
      this.position = position;
      this.sprite = sprite;
      sprite.setColor(color);
      sprite.setSize(sprite.getWidth() * scale, sprite.getHeight() * scale);
      sprite.setOriginCenter();

   }

   @Override
   public void draw(Batch batch, float alpha) {
      sprite.draw(batch);
   }

   public Rectangle getBound() {

      return sprite.getBoundingRectangle();
   }

   public Color getColor() {
      return color;
   }

   public void setColor(Color color) {
      this.color = color;
   }

   public String getType() {
      return type;
   }

   public void setType(String type) {
      this.type = type;
   }

   public Vector2 getPosition() {
      return position;
   }

   public void setPosition(Vector2 position) {
      this.position = position;
   }

   public Sprite getSprite() {
      return sprite;
   }

   public void setSprite(Sprite sprite) {
      this.sprite = sprite;
   }

}


NOTE: i tried using polygon instead of rectangle but i always got the same result (someone told me rectangles doesn't rotate {am not looking to rotate the rectangle anyway})
thank you
12  Game Development / Newbie & Debugging Questions / Re: [libGdx] how to draw rectangle around group elements of Scene2D on: 2014-06-08 18:47:28
i have added some code in this pastebin, maybe it helps a little bit ?
13  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-08 06:44:44
ok so got some results as now the bullet is rotating  Shocked

just now it is backwards, as the sprite is originaly drawn facing Left <---- so now i have to figure out how to make the bullet face the target.

if anyone is good at flipping sprites when is goes towards a target that will be nice.

thank you


the code is working it's you who is having a wrong image, by default the sprite should be headed to the right so you can just avoid all troubles and simply revert your sprite in photoshop, or you you can set your sprite xScale to -1
14  Game Development / Newbie & Debugging Questions / [libGdx]rotating group element cause rectangle misplacement on: 2014-06-08 02:43:29
Hello everyone,

I want to know how to check collision between elements inside a group and other element of the games, in other word, i want to know how to draw a rectangle around elements of the group, cause so far every time i try the rectangle is always in the wrong position, i tried using stageToLocalCoordinates but the result was always messed up (sometimes i get the rectangle in the correct position but when i move the group the rectangle seems to have a "mirror effect" {always in the opposit direction} )

thank you
15  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-08 01:20:53
i went through your code again and it seems that you are also not calling the bullet update method, and also the "structure" of some of your classes seems to be "wrong" (other members will confirm) for example in your bullet Class, why there is Final fields ? and why there is no getters/setters ?
16  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-07 23:46:49
but as you can see i make a new bullet object and bulletAnimation and use that in the batcher.draw() method.
that is in the GameRenderer class.

i dont mind re doing all my code if this makes it work.

any suggestions.

thank you

But you are not calling the load method of the AssetsLoader class anywhere, so you are using an empty variables 
17  Game Development / Newbie & Debugging Questions / Re: How to change rectangle color using keyboard? on: 2014-06-07 23:41:18
you use a key listener to set the graphics color
18  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-07 06:07:34
.....for some reason the bullet wont draw unless i use that method and that is the reason for it not to turn.
i used the bullet1 and bullet2 in the AssetLoader class for a Sprite[] and used Animation to make it loop.
could that be it?

is there another way aroung that maybe?

thank you



isn't this because your bullets sprite array is a local variable of the Load class ?
19  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-05 21:41:42
this solved my problem two days ago :

1  
2  
3  
4  
yourBulletAngle = target.sub(position).angle();

//target is a Vector2 which contain the target position
//position is also a Vector2 that contain your bullet position
20  Game Development / Newbie & Debugging Questions / Re: [libGdx] wrong rectangle position after sprite scaling on: 2014-06-05 03:37:29
Ah, looks like my ninja edit wasn't fast enough. Technically that 2nd image is "wrong" in that it's the same situation as the first, but whatever.

You're welcome.  Wink

lol oops  Roll Eyes
but i get the point
thnx man ^^
21  Game Development / Newbie & Debugging Questions / Re: [libGdx] wrong rectangle position after sprite scaling on: 2014-06-05 03:19:23
This is what is happening:


Instead of this:



Your circular sprite hides it.

yup and this solved it  Grin
1  
sprite.setOriginCenter();


thank you !!
22  Game Development / Newbie & Debugging Questions / Re: [libGdx] wrong rectangle position after sprite scaling on: 2014-06-05 03:10:03
What happens with no rotation? That occurs around the origin as well.

yup you are right, without rotating the sprite everything is perfect, but... why ? and how is this possible too ? (i will try setting the sprite origin to the center)
23  Game Development / Newbie & Debugging Questions / Re: [libGdx] wrong rectangle position after sprite scaling on: 2014-06-05 03:03:36
You could do scaling yourself:

1  
2  
3  
public void scale(Sprite s, float scale) {
    s.setSize(s.getWidth() * scale, s.getHeight() * scale);
}


That's probably the behavior you want or are most comfortable with. It simply changes the size of the Sprite without changing the position returned by getX() etc. Otherwise known as dilation about the position (bottom-left corner in libGDX) It's at least the same type of scaling you do to your rectangle in your code snippet, so it'll at least be consistent.

i also tried that before positing and the result (with 0.5scale) was different than the image below but it wasn't correct either, here it is :

and the code used is this :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
sprite.setSize(sprite.getWidth() * scale, sprite.getHeight() * scale);
public void updateSprite() {
      sprite.setPosition(position.x, position.y);
      sprite.setRotation(getAngle());
      sprite.setColor(color);

   }

   // set get rectangle ;
  public void setRect() {
      Rectangle rect = new Rectangle();

      // change the rectangle size to match the sprite
     rect.width = sprite.getWidth();
      rect.height = sprite.getHeight();
      rect.x = sprite.getX();
      rect.y = sprite.getY();
     

      this.rectangle = rect;
   }
24  Game Development / Newbie & Debugging Questions / Re: [libGdx] wrong rectangle position after sprite scaling on: 2014-06-05 02:44:03
Scaling of the sprite is actually a dilation around the sprite's origin. The origin is not necessarily the same as it's position. Read more in the libGDX docs.

I expect this would do what you want (at least for this case; you can probably come up with a more robust method since you know what else you need done):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public void setRect() {
      Rectangle rect = new Rectangle();

      float scaleW =  sprite.getWidth()*scale;
      float scaleH = sprite.getHeight()*scale;
      rect.width = scaleW;
      rect.height = scaleH;
      rect.x = sprite.getX() + scaleW / 2;
      rect.y = sprite.getY() + scaleH / 2;

      this.rectangle = rect;
}


thank you but i already figured that out  Tongue
also am scaling for 0.5 only for this example, actually my game need 0.1, but in both case, this cannot be a solution.
i also went through the doc and it still scares the heck out of me just like last year  Undecided

Quote
public void scale(float amount)
Sets the sprite's scale relative to the current scale. for example: original scale 2 -> sprite.scale(4) -> final scale 6. The sprite scales out from the origin. This will not affect the values returned by getWidth() and getHeight()
25  Game Development / Newbie & Debugging Questions / [SOLVED] [libGdx] wrong rectangle position after sprite scaling on: 2014-06-05 02:30:32
Hello everyone,

i don't understand why after scaling a sprite the rectangle that is supposed to be drawn at the same position,scale of the sprite is somehow "off" the way, here is two images that explain my problem:

sprite scale = 1


sprite scale = 0.5


and this is how am setting up the rectangle :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
// set get rectangle ;
  public void setRect() {
      Rectangle rect = new Rectangle();

      //change the rectangle size to match the sprite
     rect.width = sprite.getWidth()*scale;
      rect.height = sprite.getHeight()*scale;
      rect.x = sprite.getX();
      rect.y = sprite.getY();

      this.rectangle = rect;
   }


thank you
26  Game Development / Newbie & Debugging Questions / Re: [libGdx] what's wrong with my lookAt and move forward code ? on: 2014-06-05 00:45:28
Well your code is correct except that Math.sin/cos expect radians.

1  
2  
3  
4  
5  
6  
7  
public void moveForward() {
      position.add(new Vector2(speed, 0).rotate(getAngle()));

      // alternatively your code + toRadians fix:
     //this.position.x += Math.cos(Math.toRadians(getAngle()))*this.speed;
     //this.position.y += Math.sin(Math.toRadians(getAngle()))*this.speed;
}


PERFECT  Grin !!
i am really impressed by the build-in method of libGdx, thnx a lot man
27  Game Development / Newbie & Debugging Questions / Re: [libGdx] what's wrong with my lookAt and move forward code ? on: 2014-06-05 00:34:43
Why not this?

1  
2  
3  
public void lookAt(Vector2 target) {
      setAngle(target.sub(position).angle());
}


One liner.
Awesome  Cheesy i didn't know about that !!
now how about the "moving forward" code ?
Reminder:
i don't want the object to move toward another object, i want it to move forward based on it's direction

thanx
28  Game Development / Newbie & Debugging Questions / Re: [libGdx] what's wrong with my lookAt and move forward code ? on: 2014-06-05 00:24:32
Try using atan instead of atan2
what  Tongue ?
why ? and how ?
29  Game Development / Newbie & Debugging Questions / [SOLVED] [libGdx] what's wrong with my lookAt and move forward code ? on: 2014-06-05 00:02:44
Hello everyone,

so am still in the process of getting familiar with libGdx and one of the fun things i love to do is to make basics method for reusability on future projects, and for now am stacked on getting a Sprite rotate toward target (vector2) and then move forward based on that rotation
the code am using is this :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
// set angle
  public void lookAt(Vector2 target) {

      float angle = (float) Math.atan2(target.y - this.position.y, target.x
            - this.position.x);
      angle = (float) (angle * (180 / Math.PI));
     
      setAngle(angle);
     
   }

   // move forward
  public void moveForward() {
      this.position.x += Math.cos(getAngle())*this.speed;
      this.position.y += Math.sin(getAngle())*this.speed;
   }


and this is my render method  :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
@Override
   public void render(float delta) {
      // TODO Auto-generated method stub
     Gdx.gl.glClearColor(0, 0, 0.0f, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

      // groupUpdate();

      Vector3 mousePos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
      camera.unproject(mousePos);
      ball.lookAt(new Vector2(mousePos.x, mousePos.y));
      //

      if (Gdx.input.isTouched()) {
         ball.moveForward();
      }

      batch.begin();
      batch.draw(ball.getSprite(), ball.getPos().x, ball.getPos().y, ball
            .getSprite().getOriginX(), ball.getSprite().getOriginY(), ball
            .getSprite().getWidth(), ball.getSprite().getHeight(), .5f,
            .5f, ball.getAngle());
      batch.end();
   }


the goal is to make the ball always look at the mouse cursor, and then move forward when i click, am also using this camera :
1  
2  
3  
// create the camera and the SpriteBatch
     camera = new OrthographicCamera();
      camera.setToOrtho(false, 800, 480);


aaaand the result was so creepy lol


just to give you everything i have, here is the full Ball class (please tell me if you found any "mistake" or bad habit)

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  
public class Ball {

   public String type;
   public float speed, angle;
   public Vector2 position;
   public Sprite sprite;

   public Ball(Sprite sprite, String type, Vector2 position, float speed,
         float angle) {
      this.sprite = sprite;
      this.type = type;
      this.position = position;
      this.speed = speed;
      this.angle = angle;
     
     
   }

   // get set sprite
  public void setSprite(Sprite sprite) {
      this.sprite = sprite;
   }

   public Sprite getSprite() {
      return this.sprite;
   }

   // get set type
  public void setType(String type) {
      this.type = type;
   }

   public String getType() {
      return this.type;
   }

   // get set position
  public void setPos(Vector2 pos) {
      this.position = pos;
   }

   public Vector2 getPos() {
      return this.position;
   }

   // get set speed ;
  public void setSpeed(float speed) {
      this.speed = speed;
   }

   public float getSpeed() {
      return this.speed;
   }

   // get set angle
  public void setAngle(float angle) {
      this.angle = angle;
   }

   public float getAngle() {
      return this.angle;
   }

   // set angle
  public void lookAt(Vector2 target) {

      float angle = (float) Math.atan2(target.y - this.position.y, target.x
            - this.position.x);
      angle = (float) (angle * (180 / Math.PI));
     
      setAngle(angle);
     
   }

   // move forward
  public void moveForward() {
      this.position.x += Math.cos(getAngle())*this.speed;
      this.position.y += Math.sin(getAngle())*this.speed;
   }
   
   
}


thank you  Grin !!
 
30  Game Development / Newbie & Debugging Questions / Re: [libGdx] friendly group example on: 2014-06-03 20:22:06
Thnx everyone, here is exactly what i needed to have  Grin

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  
public class LearnGdx extends ApplicationAdapter {



   public static final int WIDTH = 800;
   public static final int HEIGHT = 480;

   private Stage stage;
   private Group group;

   private float rotSpeed = 5;

   @Override
   public void create() {
     

      // Create a stage
     stage = new Stage(new StretchViewport(WIDTH, HEIGHT));

      // Create a group and add it to the stage.
     group = new Group();
      stage.addActor(group);

      // Create images and add them to the group.
     final Texture region = new Texture(Gdx.files.internal("circle.png"));
      Image img = new Image(region);
      Image img2 = new Image(region);
      Image img3 = new Image(region);

      img2.setColor(new Color(1, 0, 0, 1));
      img3.setColor(new Color(0, 0, 1, 1));

     
      group.addActor(img2);
      group.addActor(img3);
      group.addActor(img);

      // Images are positioned relative to the group...

      img.setPosition(0, 0);
      img2.setPosition(img.getWidth()/2, 0);
      img3.setPosition(-img.getWidth()/2, 0);
      // Group is positioned relative to the stage...
     group.setPosition(WIDTH / 2 - img.getWidth() / 2,
            HEIGHT / 2 - img.getHeight() / 2);
      group.setOrigin(img.getWidth()/2,img.getHeight()/2);

   }

   @Override
   public void render() {
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
     
      stage.act(Gdx.graphics.getDeltaTime());
      stage.draw();

      if (Gdx.input.isKeyPressed(Keys.LEFT)) {
         group.rotateBy(rotSpeed);
      }
      if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
         group.rotateBy(-rotSpeed);
      }
   }
}
Pages: [1] 2 3 ... 10
 

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

The first screenshot will be displayed as a thumbnail.

Riven (18 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (30 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (41 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!