Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Discussions / General Discussions / Re: Bitcoin mining? on: 2013-04-17 08:34:01
Here's the bitcoin wiki: https://en.bitcoin.it/wiki/Main_Page

It explains things pretty good.
2  Discussions / Miscellaneous Topics / Re: Procrastination Issues on: 2013-04-05 08:42:37
Doesnt work ReBirth, tried that. Reasons for procrastination usually have little to do with "willpower" or being lazy and a lot with escaping from inner fears, like the fear to ultimately fail in some way (its a common thing in perfectionists with fear of failure, and it doesn't help if people around you have high expectations because you are intelligent).  Its also called escapism. For me, procrastinating was caused by being (mostly subconsciously) afraid that I would fail and people would discover what an horrible person I am. Not trying at all and doing something instead in which I could escape and get instant gratification (gaming) allowed me to avoid these feelings. Ultimately this approach makes you feel worse, but for the short term procrastination is a way to avoid hurt. Good news is, it is very possible to overcome.

Suggested reading: The Now Habit by Neil Fiore. Its a bit Americanish in writing style, but its quite a good guide on overcoming this.
Wow... it sounds like you're talking about me Shocked I'm also a perfectionist and my family is pretty used to me getting good grades. It's annoying having fear of man issues Sad

Fortunately for me I usually get a day or two now and then when I'm super motivated and get heaps done, but the rest of the time...
3  Discussions / Miscellaneous Topics / Re: Procrastination Issues on: 2013-04-05 08:05:39
I have the same problem, I've been doing a bit of programming lately but I just keep procrastinating the assignments I should be doing. It seems like I just don't get the motivation until the deadline gets close and I feel the pressure Undecided

I guess you need to find some way to get motivated? I don't really know any great solution.

Have a strong will first. Don't come back here until you uninstall every single games and remove internet connection. Go!

I find that if I don't have motivation then there always seems to be something to distract me (also I need the internet for studying). This might work for some people though.
4  Discussions / General Discussions / Re: How do you measure fps? on: 2013-04-05 03:59:32
For your second point you can do this (making sure to initialise t0 to something):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
int fps = 60;
//...lots of rendering
//..
//..
t1 = system.nanoTime();
long delta = ((1E+9)*1.0/fps) - (t1-t0);
t0 = system.nanoTime();
g.drawString("FPS:"+ (1E+9)*1.0/delta, 0,0);
buffer.show();
//Sleep
Thread.sleep(delta)


I usually just literally count the number of frames it displays in a second (the fps gets updated every second).
5  Game Development / Game Mechanics / Re: Calculating Theta... of What? on: 2013-04-04 08:22:10
quadratic: Maybe my brain's not working and I'm too lazy to check, but I think what you have can lead to catastrophic cancellation.  The value of disc itself as well can be very inaccurate via just plain-jane cancellation (I want to think up to 50% of the bits can be junk).

I'm not really sure if cancellation would affect it much. If b^2 was similar to 4ac then sqrt(discriminant) would be small compared to b in the calculation of the time so the cancellation error shouldn't matter much there. I've been doing too much physics where if something is small you often ignore it to simplify the otherwise unsolvable maths. This can lead to inaccuracies like you said.

Possibly if the targets velocity was very similar to the bullets velocity then "a" would be small and could have significant error, in most practical applications though the bullet should be going significantly (at least, say, 1%) faster and the cancellation error wouldn't matter.

Anyway, due to the way the bullet's velocity is calculated at the end the bullet will still hit the target even if there was large error in t; It will simply move at a different speed to BULLET_SPEED. I checked this by adding 50 to the time before the bullet velocity is calculated. For the configuration of enemy and tower I was using to test it, the time came out to be about 65 so this is a huge relative error but the bullet still hit! (it went at about half the speed)

EDIT: I read this and you're right; I've edited it to do it that way but there can still be a loss of 50% of the significant figures. There doesn't seem to be any way around that except by implementing the b^2 - 4ac calculation in quadruple precision, but 50% is still the precision of a float so it's not too bad. Thanks for reminding me, I hadn't even thought of those errors.
6  Game Development / Game Mechanics / Re: Rotation matrices on: 2013-04-04 06:18:12
Have you done much linear algebra before? Do you understand how Txz and Tz are found in that second link I posted? I might be able to explain things a bit more...
7  Game Development / Game Mechanics / Re: Rotation matrices on: 2013-04-04 05:22:45
This Wikipedia page might help, although it doesn't really have the derivation:

http://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions

I believe the matrix under the "Rotation matrix from axis and angle" heading is the same as the glRotate one.

Also this page has a derivation (it is quite terse though and doesn't explain everything):

http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/

I don't know of any textbook in particular, but a linear algebra textbook might have the derivation.
8  Game Development / Game Mechanics / Re: Calculating Theta... of What? on: 2013-04-04 03:35:32
I started making a tower defence game a while ago and wrote some code for firing slow bullets at moving targets. My method of predicting the future position was originally similar yours but I found that this method is not exact and if the target is moving too fast or is too far away the bullet would miss. My solution at the time was slightly modifying the method to make it iterative, giving more accuracy for more iterations. This works ok but I thought there should be some exact solution and this the method I worked out:

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  
public void fire()
{
    // quadratic equation for the time taken for the bullet to hit the target: a*t^2 + b*t + c = 0, where:
   double a = targetVelX*targetVelX + targetVelY*targetVelY - BULLET_SPEED*BULLET_SPEED;

    double b = 2*targetVelX*(targetX-bulletX) + 2*targetVelY*(targetY-bulletY);

    double c = (targetX-bulletX)*(targetX-bulletX) + (targetY-bulletY)*(targetY-bulletY);

    // discriminant of the quadratic formula
   double disc = b*b - 4*a*c;
    if (disc>=0){ // the bullet can't hit the target if the discriminant is negative
       double q = (b + Math.signum(b)*Math.sqrt(disc))/-2.0;
        double t1 = q/a;
        double t2 = c/q;
        double t = 0; //will be set later
       if (t1>=0 && t2>=0)// both positive
           t = math.min(t1,t2);
        else if (t1>=0)// only t1 positive
           t = t1;
        else if (t2>=0)// only t2 positive
           t = t2;
        else // both negative
           return; // the target cannot be hit. might want to do something else here as well/instead.
       
        bulletVelX = targetVelX + (targetX - bulletX)/t;
        bulletVelY = targetVelY + (targetY - bulletY)/t;
    }
}


This method seemed to work perfectly when I tested it. Also this solution doesn't use any sines, cosines, or arctangents so it could actually be faster as well as more accurate (you probably don't have to worry about speed too much but if you had lots of towers rapid firing it could matter).

I could post the derivation if anyone wants it but it would take a little while to type it all out... You can probably find find a derivation on the internet somewhere anyway.

EDIT: I made a slight mistake and left a factor of 2 out in the calculation of b.

EDIT2: Changed the calculation of t1 and t2 slightly due to Roquen's post below.
9  Games Center / 4K Game Competition - 2013 / Re: Judging panel results. on: 2013-03-28 02:50:19
Thanks for reviewing my games, appel, Drabiter, and ra4king! Especially because they both required a bit of reading to understand how to play, which must get annoying when you're reviewing 60+ games.

I guess I've probably played Mancala too much and forgotten that it can be difficult for new players; Mancala's rules can be a bit confusing and you'll probably have a few "wtf why does red get all of my balls" moments before you learn the rules properly.

I'm quite pleased with how my games did Smiley I didn't really expect many people to play CodeGolf4k but I thought I'd enter it and see whether anyone liked it and it seems that ra4king liked it a lot! (did you manage to beat the last level? That one took me a while to figure out when I created it and I knew what the trick was)

@appel: you're right about me liking math and most of the levels in CodeGolf4k require a good understanding of recursion to solve, so yeah, I guess only the nerdiest of nerds would want to play a game like that...let alone create one  Grin
10  Discussions / General Discussions / Re: Revenge of the Patent Trolls! on: 2012-12-21 06:09:39
Physicists are practically the same as mathematicians.
Mathematics is a tool which is used by physicists (and many other people), they are not the same.
11  Game Development / Newbie & Debugging Questions / Re: Wavy lines in java? on: 2012-12-17 04:26:31
Here's a Python+PyGame script I whipped up to test an idea I had:
http://pastebin.java-gaming.org/af965444e35

It works by storing a position and velocity for each snowflake. the horizontal velocity is changed by a small random amount each frame and the vertical velocity is set to a random value at the start and left the same. In order to stop the snowflakes from moving too fast I put in a friction multiplier which the horizontal velocity gets multiplied by each frame (i.e. if it is 0.5 then the velocity halves each frame). I also added a global random number which gets added to all snowflakes to simulate wind moving them in sync. You can change the three numbers on lines 4, 5, and 6 to get different results.

Here's the most important bit of code which makes the snowflakes move:
1  
2  
3  
4  
5  
6  
7  
8  
9  
    globalPush = globalPushMult*(random.random() - 0.5)
   
    for i in range(0,len(xpos)):
        pygame.draw.circle(windowSurfaceObj, clrWhite, (int(xpos[i]), int(ypos[i])), 2, 0)
        xpos[i]+=xvel[i]
        ypos[i]+=yvel[i]
       
        xvel[i]+=globalPush+xPushMult*(random.random()-0.5)
        xvel[i]*=frictionMult
12  Discussions / Miscellaneous Topics / Re: What music do you listen to while you code? on: 2012-12-07 10:29:35
I just discovered some cool music by NightRadio (made using SunVox, which he also created), I'm currently lisening to Back to the Sources.

EDIT: Here's a video for people who just want to click a big play button Grin

<a href="http://www.youtube.com/v/AHFSrxlouh8?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/AHFSrxlouh8?version=3&amp;hl=en_US&amp;start=</a>
13  Discussions / General Discussions / Re: Where are you from? on: 2012-12-06 22:12:58
I guess this would be the perfect time for me to introduce myself, something I've been wanting to do for months, just haven't found the right moment. Tongue

Well I'm a 15 year old from New Zealand, and hopefully you will see me around the WIP section soon Cheesy

[size=8pt]considering how long I've been waiting for this, that was slightly anti-climatic[/size]

Wow I didn't expect to see another New Zealander here! I live in Palmerston North, New Zealand.
14  Games Center / 4K Game Competition - 2013 / Re: M4nkala on: 2012-12-04 08:38:55
I've submitted it to Java4k and it has been accepted (link). I decided to keep the current theme and I actually think it suits the Java4k website quite well.
15  Game Development / Newbie & Debugging Questions / Re: Scrolling game on: 2012-11-23 07:08:57
Never actually done this before but a basic way of doing it would be:

1  
2  
3  
4  
5  
6  
7  
8  
9  
AffineTransform identity = new AffineTransform();

g2d.translate(-viewX, -viewY);

//
//rendering code here
//

g2d.setTransform(identity);


where viewX and viewY are the x and y coordinates of the top left corner of your view. If you wanted to stay centered on the character you could do this first:

1  
2  
viewX = charX - screenWidth/2;
viewY = charY - screenHeight/2;

Where charX and charY are the coordinates of the character.
16  Games Center / 4K Game Competition - 2013 / Re: [WIP] CodeGolf4k on: 2012-11-18 02:53:48
I suggest you to change a bit the "turn left" and "turn right" icons, so no one would confuse them with the "move forward" one. Instead of "<" and ">", what about drawing them this way : "<-1" and "1->".
Ok, I've changed that and a few other minor things (you might need to clear your java cache for it to change). Thanks for the suggestion, I thought of changing those icons a little while ago but then forgot about it.

Quote
In your game instructions, you may also add an indicative score rating, so each player would know her/his worth.
Yeah, I wrote up these instructions pretty quickly and when I rewrite them I'll probably do something like that, as well as hints because some of the higher levels are quite difficult.
17  Games Center / 4K Game Competition - 2013 / Re: [WIP] CodeGolf4k on: 2012-11-14 03:34:38
Updated again, It now has 10 levels and is at 4063 bytes
18  Games Center / 4K Game Competition - 2013 / Re: [WIP] CodeGolf4k on: 2012-11-13 03:10:56
I've updated the game, it now has four levels and the last two levels have buttons which have to be pressed before the ball can go down the hole.

It also shows a par, which is the number of blocks I solved it with.

Hint for the last level (Edit: now the second to last level):

It's a tree, use recursion.
19  Games Center / 4K Game Competition - 2013 / Re: [WIP] CodeGolf4k on: 2012-11-13 02:46:15
Error: "g.class" not found.... :S
Bad timing  Sad, I only just updated it and it might take a little while for GitHub to start hosting the new jar file.

Edit: It should work now
20  Discussions / Miscellaneous Topics / Re: Age is just a number.... on: 2012-11-11 06:10:22
I found the Lazy Foo tutorials to be really good when I was trying to learn a bit of game programming in c++. The graphics are really aren't difficult  with SDL.
21  Games Center / 4K Game Competition - 2013 / Re: Ringvibe on: 2012-11-11 04:21:49
I was bored, so I extracted your class file and ran this script (which is what I have been using) on it and it resulted in a file size of 3584 bytes (I also tested it and it runs fine).

EDIT:
I also have:
1  
java Zip2Gzip b.proguard.kz.pack b.proguard.kz.pack.gz

at the end of the script. Zip2Gzip can be found here.
22  Discussions / Miscellaneous Topics / Re: Age is just a number.... on: 2012-11-11 03:27:22
I'm 17, started programming early last year (almost two years ago).

Before that the only programming related stuff I had done was Lego Mindstorms and a bit of MATLAB when I was learning linear algebra.

Programming is pretty much just a hobby for me, I'm not planning on doing it as a job.
23  Games Center / 4K Game Competition - 2013 / CodeGolf4k on: 2012-11-10 11:38:50
I "finished" the game and submitted it to Java4k. Play it here:

http://www.java4k.com/index.php?action=games&method=view&gid=466

Original post:

A few days ago I decided it would be fun to make a game similar to Robozzle and this is what I've come up with so far:

CodeGolf4k

The aim is to get the "ball" in the hole while using as little of the program blocks as possible (hence "Code Golf").

Update: if there are bars on top of the hole then the gray buttons must be pressed first. Some levels start with the ball on the hole but the buttons unpressed.

Instructions (hopefully they make sense):

The four commands are:
^ : move forward one step
< : turn left
> : turn right
R : return to the last branch point (see below)

You can create a branch by clicking on the top or bottom of a program block and dragging to the top or bottom of another block.
Branches will cause the program to jump to the block it points to instead of advancing normally. Also, the return command will make the program continue from where it last branched (branching and returning works basically the same as calling a function and returning works, call stack included).

Selecting a colour in the palette and colouring a block will cause the command in the block to only get executed if the ball is on that colour (White means any colour).

Colouring a branch will cause it to only branch if the ball is on that colour. If a block has a white branch and a coloured branch pointing to different places it will prefer the coloured one if the ball is on that colour.

selecting the blank command at the bottom will allow you to recolour blocks without changing their command.

You can right-click on blocks to clear their command or on the start point of a branch to remove it.

Let me know what you think, suggestions are very welcome.

Hope you like it!
24  Games Center / 4K Game Competition - 2013 / Re: [WIP] Rogue 4k on: 2012-11-09 06:03:50
Any item being able to get any enchantment definitely adds fun to the game, I tried to kill an enemy with a pizza of harming at one point  Grin
25  Games Center / 4K Game Competition - 2013 / Re: [WIP] Rogue 4k on: 2012-11-09 00:28:20
Nice game! I had a cuirass of filling and a dagger of filling (+10 too, that's one tasty dagger), is this a bug?

26  Games Center / 4K Game Competition - 2013 / Re: M4nkala on: 2012-11-06 11:46:32
Thanks for the feedback  Smiley

Yeah the Neon look is used quite a lot but I haven't really had any other great ideas yet. I still have a bit of time though so maybe I'll think of something.
27  Games Center / 4K Game Competition - 2013 / M4nkala on: 2012-11-06 08:46:06
This my first time making a game for java4k and I hope you like it. It's based on the game Mancala (more specifically, 4-seed Kalah).

Play it here

Edit: Submitted, you can now play it on java4k.com here.

If you have never played Mancala before you can read the rules/instructions here.

Tell me if you manage to beat it on hard!

Updated: Fixed a bug which occurred if you sent from a pot with 13 or more balls.
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.162 seconds with 21 queries.