• Post Reply Bookmark Topic Watch Topic
  • New Topic

Developing Bowman game using java.

 
Mohammed Kz Adam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there.... am new in java programming. I'm asking for guidance on how to develop a Bowman game using java 2D.
what are the steps that i need to follow.
thanks.
 
Junilu Lacar
Sheriff
Posts: 10025
120
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Not everyone will know what that is, including myself. Can you give more specifics about the game? Since you mentioned 2D, I assume you're wanting to create some kind of graphical interface rather than a text-based interface. If you're new to Java programming, I suggest that you start with something simpler before tackling a graphical UI.
 
Mohammed Kz Adam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK...
thanks for your response.. Its a game with 2 person each of them will have Bow and arrow shooting at each other.
bowman.JPG
[Thumbnail for bowman.JPG]
this is example of bowman game
 
Campbell Ritchie
Marshal
Posts: 52580
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain the rules more. Do you have human players? How do they shoot the arrows? How do the arrows harm the other player? Write those things out in very simple words and you will have sorted out much of your problem.
 
Mohammed Kz Adam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok...
Here are the instruction..
First each party has a lifetime....
and they can only take 2 shoot at head... more-than that they will be death.
if the arrow hit some part of the body.. there lifetime will be reduce.
- the arrow that fall down show will shown.. also.
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So does the player click somewhere and then the arrow starts flying?

What will prevent an experienced player from clicking in the same place every time and winning immediately?
 
Campbell Ritchie
Marshal
Posts: 52580
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how are the arrows directed? When you know that sort of thing in detail, your game will write itself.
 
Mohammed Kz Adam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The arrow will be shooting at certain angels... the user will be specifying the angle.. and the power.

my question is...
first how will i draw the man...?
second how will i draw the arrow..?
third how will i draw the Bow....?
forth how will i mount the the arrow and bow.?
how will i draw the lifeline?

I attach here with sample show to us by the lecturer.
4ed9ad25-a337-4844-84eb-57258a7c31b4.jpg
[Thumbnail for 4ed9ad25-a337-4844-84eb-57258a7c31b4.jpg]
9327ba90-5f04-4934-bd55-10ef3d849f86.jpg
[Thumbnail for 9327ba90-5f04-4934-bd55-10ef3d849f86.jpg]
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so it's a side view. It's important to mention that, because it seemed like it was a first person view, which is way more complex.

You can override the paintComponent() method of a JPanel to do custom drawing. Cast the Graphics parameter to a Graphics2D, and you can start with drawing simple shapes, and compose more complex shapes from those. Follow this trail in the tutorials: https://docs.oracle.com/javase/tutorial/2d/TOC.html
 
Junilu Lacar
Sheriff
Posts: 10025
120
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohammed, what you're asking basically amounts to a full blown tutorial on graphics programming. There are entire books on that so I suggest you go and find one, go through it and try things out yourself. You might even want to start with the Java Tutorials on 2D graphics first. Programming is more fun when you're experimenting with different things. Then if you run into more specific problems, come back here and see if anyone can help. I'm sure there will one or few people who can. Good luck.
 
Eric Sweeten
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you remember GORILLA.BAS for QBasic? It was a game made in the procedural programming language of QBasic, and there were two gorillas standing on buildings that took turns throwing bananas at one another. They each put in their angle and speed, and had to take into account the obstacles (buildings) and wind resistance.

I imagine a game like this would be pretty simple to make. Getting the algebra done is straightforward. You have to take trajectory into account, with gravity, and things like wind resistance. The math equations for the physics of the game will be easy to come by if you don't already know it, so it's a question on your programming abilities. I also don't know your experience with 2D animation in Java. If you don't have any, you will have to learn about Thread and BufferedImage. I'd have the game loop run on its own thread, separate from the event dispatch thread. That's the way I've done my 2D games anyway.

Since you're doing a very basic archery-type game, the thread will be short, and the action you take won't be happening during the thread (I would imagine you aim then shoot, and nature takes its course from there).

For me, in a game like this the hardest part to do on my own would be making my own graphics, which I wouldn't do. I'd google search graphics and use those. If you want it completely original for the sake of a school project or to sell or something, then you'll have no choice but to do them on your own.

Best of luck to you, and if you need any more guidance, let us know.
 
Mohammed Kz Adam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Stephan van Hulst, Junilu Lacar and Eric Sweeten. I really appreciate for your time and consideration.
i will go through all the aforementioned process. and when ever i need assistance i will get back to your guys. because the project is due 10 weeks from now.
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck Mohammed!
 
Mohammed Kz Adam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.... i really need it.
 
Campbell Ritchie
Marshal
Posts: 52580
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Sweeten wrote:. . . I'd have the game loop run on its own thread, separate from the event dispatch thread. . . .
Sounds dangerous, since Swing (like most graphics packages) is not thread‑safe. There are ways to get around the problem of having to use the EDT, e.g.
  • SwingWorker
  • A javax.swing.Timer
  • I would probably prefer the Timer myself.

    I think the time has come to move this discussion to our GUIs forum.
     
    Junilu Lacar
    Sheriff
    Posts: 10025
    120
    Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    One more suggestion, Mohammed: There's a lot to know about graphics programming. Define what you want to do first, then go find information on how to do just those specific things. Don't drown yourself in all the information available.

    For example, I might approach it this way:

    1. I want draw the background as sky and ground. I'll use one color for the sky, one for the ground. How do I do that?
    1a. How do I color the top part of the screen blue?
    1b. How do I color the bottom part of the screen white?

    2. I want to draw the figure of a man. How do I do that? Is that too complicated?
    2a. Then how do I draw just the head? I want to draw a circle. Ok, there should be info about that, let's find it.
    2b. How do I draw the body? I want to draw an upright rectangle or maybe a skinny triangle. Ok, let's see how to do that.
    2c. How do I draw the body and head together?
    2d. How do I draw the legs? arms? bow? arrow?

    3. How do I change the elevation of the arms/bow/arrow to show the angle I'm going to shoot at?
    4. Do I want to show the arrow flying? How do I do that?
    5. How do I know that the arrow hit its target?
    ... and so on ...

    That's called decomposition. You break down your big problem into smaller problems then put all the little solutions together to solve the big problem.
     
    Eric Sweeten
    Greenhorn
    Posts: 21
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Junilu Lacar wrote:2. I want to draw the figure of a man. How do I do that? Is that too complicated?
    2a. Then how do I draw just the head? I want to draw a circle. Ok, there should be info about that, let's find it.
    2b. How do I draw the body? I want to draw an upright rectangle or maybe a skinny triangle. Ok, let's see how to do that.


    It is a lot easier and looks a whole lot better to use sprites. Drawing rectangles, circles, and lines is a lot to deal with and the end result is a stick figure and looks like crap. That is where BufferedImage comes into play. That's what I've used to draw sprites in my programs. Animated sprites would be stored in a static BufferedImage array.

    When it comes to the arrow, you'll have to know how to draw them slightly rotated, as the arrow is flying through the sky.
     
    Junilu Lacar
    Sheriff
    Posts: 10025
    120
    Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Eric Sweeten wrote:
    It is a lot easier and looks a whole lot better to use sprites. Drawing rectangles, circles, and lines is a lot to deal with and the end result is a stick figure and looks like crap.

     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!