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 UPDATENew screen shot  New game over screen I've been working on:  New first wave zombie sprite:  New tower: 
|
|
|
|
|
|
|
ra4king
|
 |
«
Reply #2 - Posted
2012-01-17 04:54:27 » |
|
You've only been programming in general....for 2 weeks...  It's looking good so far, keep up the good work 
|
|
|
|
Games published by our own members! Check 'em out!
|
|
ReBirth
|
 |
«
Reply #3 - Posted
2012-01-17 05:33:33 » |
|
Can't watch youtube here hehehe 
|
|
|
|
thez3r0312
Senior Newbie  Projects: 1
|
 |
«
Reply #4 - Posted
2012-01-17 05:54:40 » |
|
You've only been programming in general....for 2 weeks...  It's looking good so far, keep up the good work  Thank you! I still have a lot to figure out though! Uploaded the new game over screen!
|
|
|
|
|
asphaltgalaxy
|
 |
«
Reply #5 - Posted
2012-01-18 18:47:08 » |
|
Nice artwork as I can see. Waitin for any version to try it 
|
|
|
|
|
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  Thanks! its taken me forever to do all the art! Hopefully I can have a demo up soon!
|
|
|
|
|
ReBirth
|
 |
«
Reply #7 - Posted
2012-01-19 05:08:38 » |
|
Now you put the images. The tower is cool, looks like helmet 
|
|
|
|
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  I was going for a kind of an Iron man looking tower haha, ill post more tonight either pictures or videos.
|
|
|
|
|
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!
|
|
ReBirth
|
 |
«
Reply #10 - Posted
2012-01-21 05:16:53 » |
|
You can, with help of library such as LWJGL.
|
|
|
|
ra4king
|
 |
«
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.
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
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?
|
|
|
|
|
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.
|
|
|
|
ra4king
|
 |
«
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 
|
|
|
|
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!
|
|
|
|
|
|
|
ra4king
|
 |
«
Reply #21 - Posted
2012-01-22 10:26:19 » |
|
It's looking good, great progress! One comment: "public class ad ... " Really?!  If you want to obfuscate your code, use a tool like Proguard. Don't do it manually! 
|
|
|
|
thez3r0312
Senior Newbie  Projects: 1
|
 |
«
Reply #22 - Posted
2012-01-22 10:30:39 » |
|
One comment: "public class ad ... " Really?!  haha just laziness. But thanks for checking it out! I'm trying to get the image to follow the line right now.
|
|
|
|
|
ReBirth
|
 |
«
Reply #23 - Posted
2012-01-22 13:07:27 » |
|
Or that's really Ad class, for showing ad before you purchase the game 
|
|
|
|
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?
|
|
|
|
|
ra4king
|
 |
«
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);
g.rotate(rot,tower.x+tower.width/2,tower.y+tower.height/2); |
|
|
|
|
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
| 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); } } |
|
|
|
|
|
ra4king
|
 |
«
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(); |
|
|
|
|
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
| 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); } } |
|
|
|
|
|
ra4king
|
 |
«
Reply #29 - Posted
2012-01-23 06:48:57 » |
|
You need to reset the transform like I showed you in the previous post! 
|
|
|
|
|