I am trying to create a "picture frame" style application. I have my images added to a panel and the panel itself has a background image. This background image is used as the border. When the user increases the border I want to shrink all of the images by the border size. The issue with this is that with adjacent images the border looks "double" the size of the outer border.

I am trying to think of an algorithm that will be able to resize all of the images and position them with equal space. My application reads in the data (strings) for the different frames available which can have a wide array of different grids (4 x 4, 2 on top, one wide on the bottom, etc). I am thinking that I need to some how add some information to tell the grid if it has a neighbor or not and move the image only half the border width.

I know this is kind of confusing or jumbled but basically am asking for a way to shrink these images with equal spacing between them.

Right, I kind of realized i was mixing these a bit too much just a bit ago and decided I would essentially create a model which I can manipulate values for and then the panels can use the model to display what they need to.

My only issue with that is, lets say I have a model which has a customer. The person using the software searches the phone number "555-5555" and when he hits search it sets the Model's customer objects phone number to "555-5555" and takes him to the SearchResult screen, this screen will use that customer objects phone number to perform the search and display it. All is good, and lets say he goes back to the main screen and searches again, the customers phone number will change and therefore the search will still work.

Hey Everyone, this isnt really game related but I am having some problems creating a Java Swing application with multiple jpanels.

I am using the CardLayout which works great for switching between screens however my issue is with passing data. For example I have a MainPanel with a MenuScreen and SearchScreen, on my MenuScreen I have a textbox which one enters a phone number and hits search. This should then switch the screen to the SearchResult screen which will display the results of a SQL Query using the number provided on the MenuScreen.

I am wondering, if I am using a cardlayout on the MainPanel which I call in order to switch screens, how do I pass the new screen the phone number value?

Aside from the hiccups of getting it started the game is actually presented really well! Someone up there said "even if its flash style" but thats actually a good thing compared to most java games, good job!

Yea I figure instead of using the two systems might as well use the more flexible one which would allow for bullet, "boomerang" style weapons and even stationary melee attacks, also the method with separate "hitboxes" will allow for timed attacks such as "magic" or "iced" attacks that would linger for a while afterward by giving them a time limit until they are removed from the list of "hitboxes" in the game world.

I am not really new to this stuff just looking for different methods and styles people may implement but appreciate your comments!

and basically what I mean is a weapon which attacks out a certain distance and then comes back, like throwing a boomerang or something like that which would need to be completely separate from the player.

Yea that is true also, there are many solutions to this as you can see but the reason I havent chosen that route is a method with a separate hitbox would allow for attacks to shift out and come back in like a grappling hook type of attack etc.

Also one issue I would see with having the player hitbox expanding to fit the weapon attack area would cause movement collision to be off wouldnt it? Since the same hitbox is used for collision.

Yea that would work much easier but the problem with that is it will only allow attacks when the enemy and player are intersecting, which doesn't give much room for different types of attacks such as longer swords, or things like that since you dont necessarily have to be "intersecting" the enemy to attack it. But thanks for the example and suggestion, these are all good and would work all just depends on what you are looking for and the more ideas the better!

@GabrielBailey74 Thanks, I mean how to handle the collision of the attack, like if the attack is button is hit, do you just add a "hitbox" to a list in the game world and then test it against enemies in range as Mads stated?

Or do you just have one "attack hitbox" in the player class, that gets manipulated based on the current weapon and when cycling through the game world entities, check if player is attacking and if it is, test that hitbox against nearby enemies.

Hey everyone, I was just curious as to how you all would implement real time combat in a 2D "action game." Such as a game where a character walks around and swings a sword or punches enemies.

I have heard of having hitboxes, however am not sure how to implement such a thing. One idea I have had is for example, if the player has a long sword in hand, and the sword has a "use" function, when this use function is called it adds a "hitbox" to the game world, similar to adding bullets to a game world which has bounds and is tested against all entities in the world, however this hit box just stays still and disappears after a designated time (if the sword swing lasts 1 second then it will last one second and then be removed). But this seems kind of limiting, and also requires all Weapons to have an instance of the game to be able to add the hitboxes to it.

Or I was thinking the player will just get the bounds for the weapons attack hitbox and just add it to the world, but anyways.

My first ever snake game, I used an ArrayList of Points. Every time the snake moves, I add a new Point for the new head and remove the last Point. However I don't remove the last point when capturing the apple Also the easiest way is to not think about pixels when doing this, just think about your data. You only convert to screen coordinates when rendering. So if you have a grid of 20x20, each point would have an x and y between 0 and 19.

Good luck

Haha much cleaner than the chain reaction idea, I knew there was a simpler way, thanks! Its always nice to see what other people think to clear your brain a bit haha

Recently I have been working on a bunch of random projects, havent completed anything and they have ranged from top down shooters, asteroids style games, match 3 games etc. So I decided to screw all the complicated designs and just make a complete snake game real quick, however I then realized I HAVE NO IDEA how to properly design a snake game.

I know there is no "right" way to design it but I cant even figure out any way to do it. The way I have been trying to do it is without a grid just using bounding boxes for collisions and having the snake move at a fixed distance every couple of frames or so. Why would I need a grid?

My current design is working, but it seems like its stupid. It is basically a Snake which is made up of a list of Body parts, each update I save the head's old position, update the head, and then loop through each of the Body parts from the end of the list to the front and set each body part to the location of the one next to it, and if its the first element in the array I set it to the "old head" position. It works but seems sloppy or hacked together.

I have a quick question though, how do you get the buildings to not display the roof when the player is inside of it?

Do you just have each building check and see if the player is within its bounds every update and not draw the roof if it is? Or does the player check if it is inside of the building? (really random specific question lol sorry but just sparked my curiosity).

Yea seriously, has he not contributed anything to LWJGL or anything like that? Does he even acknowledge...anything to do with it?

He has donated to LWJGL in the past and the library is credited on the credit page.

Its likely he's way too busy to have time to spend or think about JGO, especially now that he has to run a company.

Ahh thats good to hear! Of course I figured he has way too many things on his mind at the moment to really detract from anything other than his company and minecraft, it just sounded like he didnt do anything in the post but its good to know he has!

Markus has stuck with a pretty old version of LWJGL because it works on more systems than the later versions. It might have been helpful if he'd contributed some coders and / or some of that giant pile money he's made off the back of it to getting that stuff fixed and providing testing. Hm.

Cas

Yea seriously, has he not contributed anything to LWJGL or anything like that? Does he even acknowledge...anything to do with it? I remember when he posted Minecraft here for people to try it out before it became big, and now hes gone..

*edit* lol he mentioned tigsource but not javagaming, that would have been awesome.

Nobody responded to having a place to put all the featured game as some sort of "java portal" (since this site already has a lot more traffic then most java portals ever get) could help get java games exposure, featured games feedback and maybe even some money for developers and the site? Are my posts invisible or is this just a bad idea lol

Wow guys I never realized I had such a great impact on this community, always thought I was more of just a random person but glad that a lot of you have taken note of me, appreciate it!

As for a suggestion, I dont think I have any that will live up to the expectations you all seem to have for me, but maybe have a page for where the Featured games can be displayed in a "portal" type fashion. Which could eventually lead to some money for the site if gamers catch on to it and place some ads, or even some money for the developers and start a portal for java games right here. Although that's definitely a lot harder to do than it is to suggest.

I cant help all the way at the moment but as for the styling of the text box, the problem with using a JTextArea you can not stylize individual lines of text, if you want the text to be bold all of the text will be bold. I believe you can use a JEditorPane to stylize text in a better way though.

This is not really what you were asking for but maybe sell a Level/Quest editor which people can use to make theirown levels and quests that they can share which will help you add content for people whom just want to play the game, but also for people whom want to create content for the game and you would not have to worry about peoplesharing levels because it would be a good thing.

Just an idea off the top of my head. Also if it is an applet or something could you just "enable" the level on their account if they pay for it?

Thanks for the code and example, although I seem to see stuttering in your example also...I guess this is just something that will happen no matter what, and in a game setting I doubt it will be noticeable

OK I notice the stutter, isn't the app small enough to just post the code here?

I linked to the source code, although Idk what happened to my link to the app...did you really see the app or did the link disappear? also the code is extremely basic, but I made it using my "library" but it is really only 4 files, 2 of them are significant, GameScreen (where the block is moved and drawn) and Game (the loop)

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