Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-20 08:03:41
I made some origami! It's a fawn and a five intersecting tetrahedra. Cheesy
   
2  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-15 07:14:39
Drew the art for the next update to City Jumper, and I'm really proud of it. Cheesy Right now it's just a mock-up but today I'm going to implement it in code.



Also made a new pixel person: Cheesy
Click to Play
3  Game Development / Game Mechanics / Re: Assistance with Simple Euler Physics Integration on: 2014-07-29 08:26:42
Gah, I accidentally hit appreciate on your comment, Roquen. No harm done. Cheesy

Anyways, I have time to spare so I'll explain this as best as I can.

Adding to what Roquen said, you only calculate the delta time once when you instantiate your Player class. Delta time is the time between the last frame and the current frame, so saving the value is useless. In your isRunning() method, add store the current delta time and use that. Also you can shorten your if statements. Instead of
if(statement == true)
, you could simply write
if(statement)
. Last thing, avoid creating new objects in methods called repeatedly. libGDX's Vector2 class has a method called
set(float x, float y)
so it's better to call that method than create a new Vector each time. Now onto the actual physics. Cheesy

If I understand correctly, you want the player to accelerate to a maximum speed, and 'drift' to a stop. Here's my usual approach:

Lets define some values first. Suppose our object accelerates at 20 pixels per second. And our maximum speed (otherwise known as terminal velocity) for both the x and y axis is 200 pixels per second.

Check which movement keys are pressed. If up is pressed, set acceleration.y to our acceleration value. If up is not pressed, set acceleration.y to zero. For down, set acceleration.y to the negative of our acceleration value or zero if not pressed. Repeat for left and right, but on the x-axis instead.

After the acceleration vector has the correct components, multiply it by deltaTime. This will normalize the acceleration values based on the time elapsed so the player moves at the same rate regardless of frame rate.

Then, add the acceleration to the velocity. Now, we need to cap the velocity in case it exceeds our maximum speed (otherwise known as terminal velocity). Add a couple if statements to check if the x and y axis of the velocity exceed our maximum speed, and cap them if they do. Viola, our player moves smoothly! But how do we stop?

When a key is released, it's acceleration component is set to zero. Newton's first law of physics states objects move with a constant velocity (or stay at rest) until acted upon by an outside force. To stop our object, we have to simulate friction (the outside force). Don't worry, this is really simple.

Before, when we checked if each key was pressed, we set it's respective acceleration value to zero if it was released. So if up was released, acceleration.y would be set to zero. This means our object should start slowing down on the y axis. Use a simple if statement to check if acceleration.y == 0, then multiply velocity.y by some friction or damping value. The higher the value the more gradually an object will slow down. I usually use 0.95, but you can play around with different values to find what you like.

Lastly, add our velocity to our position and reset our acceleration back to normal by multiplying it by the inverse of delta (1 / delta). This is important, otherwise you'll keep multiplying the acceleration by delta until it reaches zero.

Now we're done! Cheesy Your object will accelerate to a maximum speed and slow down when you let go of the movement keys. Here's some really basic pseudo code you can use:

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  
// I should probably have used pastebin for this... I didn't realize how long it'd be.

// Our constant values
final float ACCELERATION = 20F;
final float MAX_SPEED = 200F;
final float DAMP = 0.95F;
float deltaTime = 0;

Vector2 acceleration, velocity, position;

public void update() {
   // I usually pass the delta time as a parameter to the update() method,
  // but you can do whatever you want.
  deltaTime = Gdx.graphics.getDeltaTime();

   // Step one: Check each key.
  if(up.isPressed()) acceleration.y = ACCELERATION;
   else acceleration.y = 0;

   if(down.isPressed()) acceleration.y = -ACCELERATION;
   else acceleration.y = 0;

   if(left.isPressed()) acceleration.x = -ACCELERATION;
   else acceleration.x = 0;

   if(right.isPressed()) acceleration.x = ACCELERATION;
   else acceleration.x = 0;

   acceleration.scl(deltaTime); // normalize the acceleration.

   velocity.add(acceleration); // Add the acceleration to the velocity.

   // Check if the velocity is greater than the maximum speed
  //
  // By using the absolute value, we can avoid two clauses as we will not
  // need to check if the velocity is less than the negative maximum speed
  // since absolute value returns the distance a number is from zero.
  //
  // Signum returns 1 if the value passed in is positive, zero if it's zero, or -1 if it's negative.
  // This preserves the direction of the velocity.
  if(Math.abs(velocity.x) > MAX_SPEED) velocity.x = MAX_SPEED * Math.signum(velocity.x);
   if(Math.abs(velocity.y) > MAX_SPEED) velocity.y = MAX_SPEED * Math.signum(velocity.y);

   // Dampen our velocity to drift to a stop.
  if(acceleration.x == 0) velocity.x *= DAMP;
   if(acceleration.y == 0) velocity.y *= DAMP;

   position.add(velocity);

   acceleration.scl(1 / delta);

   // Tada! We're done. :D
}


Also, welcome to the forum! Wink
4  Discussions / Miscellaneous Topics / Re: Game art for programmers with non-existent budgets on: 2014-07-26 07:45:02
Instead of making your own art, you could use the many free assets available around the internet. Sites such as www.opengameart.org offer lots of assets which you can use even in commercial games by doing as little as adding the authors' name in your credits. There's things like this 16x16 fantasy tileset and Kenny's incredible public domain assets.

A google search for public domain pixel art pops up a lot of great results. Good pixel art is reeeally hard to make. Luckily, this world has some nice people who give away their work for free. Cheesy
5  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-07-23 14:23:52
Made some progress on my Space Game: Gfycat link
6  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-07-20 21:49:24
@mag
That's really neat! Is it rendered in 3D or 2D? I'm guessing 3D by the shadows but I'm not sure. Also, are you using a noise function for that?
7  Game Development / Newbie & Debugging Questions / Re: Having a Problem with ArrayLists and Objects on: 2014-07-20 08:42:21
Instead of storing the objects' index for later, you could loop backwards from your fluidObjects array and remove the objects right then and there.

ex.
1  
2  
3  
4  
5  
6  
7  
8  
for(int i = 0; i < worldObjects.size(); i++) {
    for(int j = fluidObjects.size() - 1; j >= 0; j--) {
        if(shouldRemove) {
            fluidObjects.remove(j);
            continue;
        }
    }
}


I'm not sure why your code creates thousands of objects. Maybe worldObjects contains a ton of fluidObjects arrays for some reason?

I'd also avoid confusing variable names such as naming an ArrayList i because it's easier to forget the objects' purpose. Cheesy
8  Games Center / WIP games, tools & toy projects / Re: Project NAH - A sandbox survival platformer. on: 2014-07-15 20:46:51
Perhaps simply have the camera stop following the player once they reach an edge. Really nice project, by the way! One thing though, falling and jumping look very linear. I would suggest adding acceleration so the player jumps following a smooth parabola and gains velocity while falling down.
9  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-07-10 20:12:55
Creating a falling meteor space-type game and this is what I have so far:
Click to Play


Random polygon generation, lots of trig, and keeping my code clean for once took up most of the time spent making this project. However, I'll have to replace the polygons with proper textures and the turrets will end up being spaceships so all that math was for nothing. Oh well, at least I learned something. Cheesy
10  Games Center / WIP games, tools & toy projects / Re: Jumproom on: 2014-07-05 20:21:57
Okay, first, reeeally like the graphics. They're so well done and fit perfectly! I've noticed the background is rather static and boring however, simply making the clouds move with some paralax would really add some sense of dimension to the game.

I completed all levels and one warp level with three stars except for level 8 and had tons of fun! I'm not sure it's possible to get the second star in level 8 without falling off the map unless you move it down a block. Also, there's a two second delay before the restart and main menu options appear when you fall down the map which quickly gets annoying. I could also jump across spikes by repeatedly clicking as Bearded Cow mentioned.

How many warp levels are there? I only found one and cannot find the rest.

Good game, nice job! Cheesy
11  Discussions / Suggestions / Re: Pre-WIP section on: 2014-07-01 17:19:42
In addition to a pre-WIP, I think we also need a pre-pre-WIP to document game ideas and get input on them before starting to code them. Cheesy

Seriously though, you don't need to post on this forum if you want to document your progress. There's personal blogs such as Wordpress or Tumblr for that. Cheesy Not yet playable is still WIP; for example, Rayvolution's Retro-Pixel Castles doesn't have any gameplay, but I'd definitely consider it a WIP over a pre-WIP.
12  Java Game APIs & Engines / Engines, Libraries and Tools / Re: libGdx setting a trajektory for a object to move on: 2014-07-01 10:21:51
You could use the four basic equations of kinematics to determine the x and y position of an object relative to its velocity and the amount of time elapsed, but really, it's much easier to just apply gravity to your objects. You simply need three vectors;
Vector2 position
,
Vector2 velocity
, and
Vector2 acceleration
. Set the y component of the acceleration vector to your gravity value (I usually use -10) and the x component to 0. Then set the x and y components of the velocity vector to the speed of your object. In your update method or loop, add the acceleration to the velocity, then add the velocity to the position, ex;
velocity.add(acceleration)
and
position.add(velocity)
.

If you have an angle instead of x and y components for your velocity, you could get the normalized x and y components of the angle with some trig then multiply them by how fast you want your object to move:
x = cos(angle) * xSpeed
and
y = sin(angle) * ySpeed


With this bit of simple physics, your object will move on a parabolic curve. Hope this helps!
13  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-22 19:58:37
Intel Core i5 1.7 GHz
Intel HD Graphics 4000
4GB RAM
Windows 8

Solid 2000 FPS. Really surprised it's that fast. Shocked
14  Games Center / Archived Projects / Re: Flubber Space on: 2014-06-21 17:49:05
It's more worth your time to use libGDX, as Slick2D is basically dead.

Btw, I would really recommend GifCam.
15  Discussions / Miscellaneous Topics / Re: Longest program you have written? on: 2014-06-18 01:00:32
You'd end up with something similar to FizzBuzzEnterpriseEdition. Cheesy
16  Discussions / Miscellaneous Topics / Re: Interesting Profile pictures on: 2014-06-17 18:41:56
I'm not sure what that could be besides a hat. Tongue

I made my current avatar last summer and uhm... there's really nothing special about it. Sky blue is my favorite color, and I'd love to fly hence the wings. That's about it. Smiley
17  Discussions / Miscellaneous Topics / Re: Code-style: Cringe pics on: 2014-06-05 20:00:57
I can't resist the urge to edit your code, Rayvolution:
1  
public void setAccentMode(boolean on) { accentMode = on; }


I found this:
1  
2  
3  
4  
5  
int length= 0;
for(int i = 0; i < array.length; i++){
    length++;
}
System.out.println("Array has " + length + " elements.");


Going through some old code, I found this:
1  
2  
3  
4  
5  
6  
7  
8  
if(someCondition) {
   if(anotherCondition) {
      if(yetAnotherCondition) {
         SomeObject object = aParameter;
         if(ANOTHERcondition) {
            if(lastCondition) {
               AnotherObject object2 = getOtherObject();
               if(object2 != null) {

I removed the conditions and changed object names to remove confusion, my code wasn't THAT terrible. But six nested if statements, anyone?
18  Games Center / Featured Games / Re: [Slick2d] Retro-Pixel Castles - Top Down Survival Mayhem! on: 2014-06-03 19:15:08
If you do put a box around the logo, also include the blurbs. They're hard to read when over lava or stone.
19  Discussions / Miscellaneous Topics / Re: Random syntax tweaks! on: 2014-06-01 21:35:59
Dart has really nice constructors and methods with default values:

1  
2  
3  
4  
String method(String foo, {String bar:'default value', String ball:'bat'})

var variable, number, name;
SomeObject(this.variable, this.number, this.name);
20  Discussions / Miscellaneous Topics / Re: Setting up a website for a complete noobie on: 2014-05-29 20:20:20
If you have $4 a year, you could go with http://123systems.net/. I'm planning to use them in the future, because 000webhost sometimes pops up ads on your site when it loads which can deter some visitors.
21  Discussions / General Discussions / Re: New feature: topic labels [solved] on: 2014-05-06 20:12:50
I like this update, looks great! Could you get the labels to also show up in the "Recent Posts" section on the homepage?
22  Discussions / General Discussions / Re: The Differences between Java and JavaScript. on: 2014-04-27 21:03:06
Java to Javascript is like ham to hamster.
23  Game Development / Newbie & Debugging Questions / Re: New vector from known angle on: 2014-04-14 16:46:36
You don't need to calculate a new vector from the angle of reflection. You can just invert the y component of vector A to get vector B.
24  Game Development / Newbie & Debugging Questions / Re: Is this book good for libgdx beginners ? "Beginning Android Games" on: 2014-03-26 19:26:32
Beginning Android Games was written by the author of libGDX. Smiley Throughout the book, you put together a sort of "mini libGDX" while learning the Android API and using it to make 2D and 3D games. I recommend it, it's a really great book.
25  Discussions / General Discussions / Re: Great programming book offer. on: 2014-03-25 01:50:12
@Rayvolution

It depends what you want to do. If you want to figure out a simple problem you have in your program, Google's the way to go. But for learning new programming concepts or languages, books are often much better to learn from.

Mr. Somebody posting programming tutorials online could be anybody, whereas those expensive books are (usually) written by authors with lots of experience and knowledge in their field. The internet is a large patch-work of various resources contributed by any random somebody sitting in front of a computer. You may not find exactly what you need, or the author of said resource may not necessarily be doing what they're doing very efficiently. Sometimes you may find book-quality information, but it's not very common and hard to find. Fancy books (again, usually) contain all that nice high-quality information you rarely find online. They're also more in-depth and cover a lot more material than a bunch of internet sources.

TL;DR: Books are written by authors who know what they're doing. The internet is cats.
26  Discussions / General Discussions / Re: JDK 8 is released on: 2014-03-19 11:22:45
I bet those 30% are mostly stingy public schools who don't want to spend money upgrading any of their computers. Tongue Windows XP is ancient, like Jev said, this gives them a reason to upgrade.

Java 8 looks awesome. I can't wait to learn and use all the new features. Smiley
27  Games Center / Showcase / Re: City Jumper on: 2014-03-17 20:01:14
I am glad to announce update 1.2! This update adds a bunch of new settings including a toggle between jumping on tap and on release. You can also mute the sounds and change the sensitivity. Here's a picture:



Enjoy!
28  Games Center / Showcase / Re: City Jumper on: 2014-03-12 22:00:52
Thanks for the feedback! I tried jumping on tap, but it made the game much too easy in my opinion. I've also been told this different jumping mechanism differentiates my game from the rest, which may motivate players to adapt the different jumping style and play more. I'll try implementing it again and may add a toggle for it if enough people want it.

On other news, I released version 1.1! It contains some performance improvements and fixes a bug where the pause popup doesn't show if the game over popup is open.
29  Games Center / Showcase / City Jumper on: 2014-03-11 01:52:58


City Jumper is a new, fun and addictive game by Float Play. You play as a person jumping from rooftop to rooftop across a cityscape to get as far as possible.

Screenshots:






Simple controls. Tap on the screen, and let go to jump. The longer you hold your finger on the screen, the higher your jump.





-------------------------------------------

Post-creation thoughts:
This is only my second game, and took around a month to make (along side a ton of school work). I learned soooooo much and couldn't be happier. Indeed the hardest part was polishing it up and patching bugs. The game portion took about two days, but making it look nice, finding bugs, and getting it to run smoothly on low-end devices took foreeeeeever. Advertisement and leaderboard integration was also difficult, specifically leaderboards. Google Play Game Services is just waaaaay too difficult, and I ended up ditching it for Swarm. Swarm took an hour to get set up and working correctly, versus two days and tons of frustration with GPGS. I really recommend Swarm to integrate achievements, in-app purchases, and of course leaderboards into your game. They even support libGDX!

In any case, the experience I gained and knowledge I learned was more than any book or tutorial could teach me. If you want to get better at making games, then make games. I made the mistake of reading too many tutorials because I was paranoid I wouldn't know how to properly write a game and end up with a conglomerate of code and a poorly-made piece of software one might call a "game". This time, however, I didn't worry about how messy my code was until I had something working. Then I refactored pretty much everything I wrote and ended up with organized code and a nice game. The point is, don't worry how unpleasant your code is. Your original code will never make it to the final version anyways. By the time you finish, you'll have gone through half a dozen re-writes of almost every class you've written. Moral of the story: Keep calm and create games. Wink

As always, I'd appreciate any feedback or advice given. I'm constantly looking for ways to improve my games, so a little kind criticism never hurts. Cheesy And of course, if you find any bugs tell me. I dislike those pesky bugs as much as anyone, so I'd be more than happy to get rid of them.

Also, yes, this game is only for mobile devices. I need to get money somehow, so this is my business. It's only for Android right now, but an iOS version will come soon; when I get enough money to pay for Apple's ridiculous development fee.
30  Game Development / Newbie & Debugging Questions / Re: libGDX, AdMob, and Google Play Leaderboards on: 2014-03-09 04:28:04
Well saucymeatman sir. I guess you just nominated yourself to implement leaderboards in my game. Tongue Chop chop, write the code.
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.

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

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

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

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

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

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

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

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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!