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   
Pages: [1] 2
  ignore  |  Print  
  Java tower defense game  (Read 10217 times)
0 Members and 1 Guest are viewing this topic.
Offline thez3r0312

Senior Newbie


Projects: 1



« Posted 2012-01-15 01:22:41 »

So I'm very new to java I've been programming for only about 2 weeks. The past couple days I have been working on this tower defense game. Its in its very early stages many things don't work in it however for two days of work I'm pretty happy! Let me know what you think all feed back is welcome! I'll continue to post as I change things!

<youtube> http://www.youtube.com/watch?v=l4XrAnWxev4 VIDEO 1
               http://www.youtube.com/watch?v=Ymww6vpgndA VIDEO 2 UPDATE

New screen shot


New game over screen I've been working on:


New first wave zombie sprite:


New tower:




Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #1 - Posted 2012-01-17 03:22:16 »

Any thoughts?
Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2012-01-17 04:54:27 »

You've only been programming in general....for 2 weeks... Shocked

It's looking good so far, keep up the good work Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2012-01-17 05:33:33 »

Can't watch youtube here hehehe Grin

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #4 - Posted 2012-01-17 05:54:40 »

You've only been programming in general....for 2 weeks... Shocked

It's looking good so far, keep up the good work Smiley

Thank you! I still have a lot to figure out though! Uploaded the new game over screen!
Offline asphaltgalaxy

Junior Member


Medals: 1



« Reply #5 - Posted 2012-01-18 18:47:08 »

Nice artwork as I can see. Waitin for any version to try it Smiley
Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #6 - Posted 2012-01-19 02:23:43 »

Nice artwork as I can see. Waitin for any version to try it Smiley

Thanks! its taken me forever to do all the art! Hopefully I can have a demo up soon!
Offline ReBirth
« Reply #7 - Posted 2012-01-19 05:08:38 »

Now you put the images. The tower is cool, looks like helmet Grin

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #8 - Posted 2012-01-19 22:52:15 »

Now you put the images. The tower is cool, looks like helmet Grin

I was going for a kind of an Iron man looking tower haha, ill post more tonight either pictures or videos.
Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #9 - Posted 2012-01-21 01:34:35 »

Does anyone know if i can use a 3d modeler with java? Like blender or something like that.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #10 - Posted 2012-01-21 05:16:53 »

You can, with help of library such as LWJGL.

Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #11 - Posted 2012-01-21 06:49:03 »

LWJGL is a simple binding to OpenGL. OpenGL has no clue what a model is. All it knows how to do is render geometry and textures.

@thez3r0312
To load a model into OpenGL, you have to use a library that allows you to do that. I believe libGDX has classes that load OBJ and MD5 models.

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #12 - Posted 2012-01-22 01:58:50 »

So i want to make my towers and enemies like this:


Anyone have any ideas how i would make my characters/towers 3d like this and animated? Also anyone have an example code of a targeting system for the towers that makes towers pivot and follow the characters.
Offline ReBirth
« Reply #13 - Posted 2012-01-22 05:53:17 »

animation is simply change sprite in constant time. Target an enemy and calculate the rotation for tower so it looks like following, and shoot in desired rate.

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #14 - Posted 2012-01-22 06:25:06 »

animation is simply change sprite in constant time. Target an enemy and calculate the rotation for tower so it looks like following, and shoot in desired rate.

wont i need multiple images for that though? otherwise the whole tower image is going to shift instead of just the barrel of the tower.
Offline ReBirth
« Reply #15 - Posted 2012-01-22 06:29:18 »

For creating smooth animation, it's pretty common to have multiple sprites/images, except yours are procedural generated. If you want whole tower to rotate, it'll be neat to have 3D approach.

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #16 - Posted 2012-01-22 06:39:01 »

Considering i have very little java experience this sounds quite complicated. Basically if i understand correctly i have to have the tower target the enemy then depending on its location choose an image that accurately depicts where is should be facing?

and to make this smooth ill need at least 20 images that each are slightly rotated in order to get a smooth rotating image?
Offline ReBirth
« Reply #17 - Posted 2012-01-22 06:49:13 »

Yeah you can do that, but not efficient I think. You can have less image by rotating with code (generated on fly) but it's expensive with java2d so you better bring it to opengl. My suggest is to leave animation first and create logic first. In the end you'll have a game where the towers are static but shoot enemy with right directed bullets. Then you can enchant animation.

Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #18 - Posted 2012-01-22 06:52:49 »

You don't need many images to produce a smooth animation. For example, a smooth looking walking animation is only 3-4 images. Animation is very easily simulated with little amount of frames Smiley

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #19 - Posted 2012-01-22 06:59:03 »

im gonna do the shooting system tonight, and ill put up a video of it, if anyone can suggest how i do the image animation after you see it let me know. I have some ideas but i really dont know if they are going to work!
Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #20 - Posted 2012-01-22 10:16:50 »

New Video: http://www.youtube.com/watch?v=Ymww6vpgndA

Put up the new video showing the towers firing, I'm gonna try and get the towers to rotate with the line in order to get 3D feel.
Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #21 - Posted 2012-01-22 10:26:19 »

It's looking good, great progress!

One comment: "public class ad ... " Really?! Shocked
If you want to obfuscate your code, use a tool like Proguard. Don't do it manually! Pointing Tongue

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #22 - Posted 2012-01-22 10:30:39 »

One comment: "public class ad ... " Really?! Shocked

haha just laziness. But thanks for checking it out! I'm trying to get the image to follow the line right now.
Offline ReBirth
« Reply #23 - Posted 2012-01-22 13:07:27 »

Or that's really Ad class, for showing ad before you purchase the game Tongue

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #24 - Posted 2012-01-23 05:35:50 »

i really cant figure out how to make the tower rotate toward enemies, anyone have any ideas?
Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #25 - Posted 2012-01-23 05:45:45 »

All you need is the rotation angle of the tower when it faces the enemy:
1  
2  
3  
4  
5  
double rot = Math.atan2(enemy.y-tower.y,enemy.x-tower.x);

// then when rendering:

g.rotate(rot,tower.x+tower.width/2,tower.y+tower.height/2);

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #26 - Posted 2012-01-23 06:09:39 »

Ok so here is my code and its getting an error,

1  
2  
3  
4  
5  
6  
7  
8  
9  
//Tower
     double rot;
      for(int i = 0; i < tower.length; i++){
         rot = Math.atan2(mobs[i].y - tower[i].y, mobs[i].x - tower[i].y);
         if(towerID[i] != air) {
            g.drawImage(aa.f.bp.tower[towerID[i]], tower[i].x, tower[i].y, tower[i].width, tower[i].height, null);
            g.rotate(rot, tower[i].x + tower.length / 2, tower[i].y + tower.height / 2);
      }
      }
Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #27 - Posted 2012-01-23 06:17:39 »

you should be rotating before drawing the image then you need to reset the transform:
1  
2  
3  
g.rotate...
g.drawImage...
g.getTransform().setToIdentity();

Offline thez3r0312

Senior Newbie


Projects: 1



« Reply #28 - Posted 2012-01-23 06:41:16 »

ok so i have some rotation but its very random and all over the place, and when i place a second tower it rotates around the first one. Anyone see why?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
//Tower
           double rot;
            Graphics2D g2d = (Graphics2D) g;
            for(int i = 0; i < tower.length; i++){
               
               rot = Math.atan2(mobs[i].y - tower[i].y, mobs[i].x - tower[i].y);
               if(towerID[i] != air) {
                  g2d.rotate(rot, tower[i].x + tower[i].width / 2, tower[i].y + tower[i].height / 2);
                  g.drawImage(aa.f.bp.tower[towerID[i]], tower[i].x, tower[i].y, tower[i].width, tower[i].height, null);
            }
            }
Offline ra4king

JGO Kernel


Medals: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #29 - Posted 2012-01-23 06:48:57 »

You need to reset the transform like I showed you in the previous post! Tongue

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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 (31 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 (28 views)
2014-07-23 21:07:15

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

ctomni231 (60 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!