Question:
What code would I use to make this fairly simple Java game?
anonymous
2008-10-29 16:13:19 UTC
Basically, this is what I want. I want to be able to show a picture like this:

http://www.dioceseofgrandrapids.org/graphics/hallway.jpg

And then, if they click on a door, it will go inside, and show another picture of the room, and so on and so forth.

Either that, or it will show that picture, and when I type in, :enter door, the picture will change.

Seems fairly simple to me, but I don't know how to import pictures and stuff. I made a simple text based game, and I would think it wouldn't be much harder.....
Five answers:
JakesRosenblum
2008-10-29 19:51:22 UTC
God are you a homosexual or something?

My brother's stalker was here and there was a commercial for a tv show that said "Sex with mom and dad" And I was like "What a weird name," And she's like "You'll never have 2 worry about that," And She's stupid. She insults me in my own home so I sad "Why do you worry about sex with your mom and dad? Don't insult me in my own home you *****"

And then I told Alex and she was like "I would've been so much meaner, and she had no right to be mean, I'm sorry,"

And I laughed
anonymous
2008-10-29 16:55:06 UTC
This is easy enough. You will have a frame and a panel inside that frame. The background for the panel will be the first picture. The frame will have a "mouse listener" that has several methods. Basically you can actually get where in the frame the mouse clicked. You can check bounds, and if the mouse clicked on the door (within a certain area), the panel background changes.



There are plenty of tutorials that can tell you how to make a frame with a panel in it. I think you can start with:



//imports

class Room extends JFrame implements MouseListener

{ }



Java is the best language to do this type of program. Good luck.
npolynomial
2008-10-29 16:35:56 UTC
I hope this helps...

Firstly, when you think about it, most programming languages cover up ALL of the small details of what the computer actually does. For example, writing text to the screen ( a text based game ) is much easier (for the processor to do) than to bring up an image. A lot of communication occurs between the hard drive, RAM, graphics card, and processor.



You will have to find a graphics library and make reference to these things within your source code. The graphics library contains instructions to allow your program access to the graphics card drivers. Also, since every graphics card has different features, the library also provides a somewhat universal approach to dealing with that.



In c++, for example, one common library is called OpenGL and often the glut wrapper is used to provide a very simple interface with that library. giving you commands like glBegin(GL_LINES); to draw lines to the screen.



Anyway once you figure out how to load images into memory and display them on the screen, and once you've obtained mouse control, you can do very simple checks to determine whether or not they've clicked on the door.



You are right the basic idea is simple enough... so goodluck with your project.



If you have more questions I'd be happy to help!
anonymous
2016-04-03 07:12:20 UTC
With Java, you can distribute the CLASS files (and any data files the program references during execution). Anyone's JVM should recognize them properly. That said, if you have multiple CLASS files, it is common practice to combine them into a single JAR file that can be ported about and run relatively easily. There are a number of utilities for doing this, personally I use FatJar with Eclipse but you may find that you prefer another utility. It's best to come up with your own ideas for games. That way you're exercising your imagination, and also making it more likely that your game logic will be new, which forces you to think about the implementation rather than just slapping together code you found somewhere else and hoping it works. Also, it's best if you make use of procedural generation techniques in order to squeeze more gameplay value out of the same logic. I would suggest something like one of those turn-based combat RPGs (think Sonny, Murloc RPG, Epic Battle Fantasy, and the like) with randomly generated enemies/items, or a maze-running game with a randomly generated maze layout. Both of these can be done in a text-based format, and both provide the opportunity to start very simple and gradually add features (of whatever kinds you like) as you get more comfortable with the framework.
ste a
2008-10-29 16:55:33 UTC
I've used OpenGL/GLUT and I think that for what you want to do, you'd have the best success making a Java Applet. Do an internet search for a Java Applet Graphics tutorial and you're sure to find step-by-step instructions for working with images in Java.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...