Tips for games made in swing [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
People said I was mad, people said I was crazy. They told me to use slick2d or lwjgl but i decided to make my game in swing so please don't tell me to use some libary, that would not answer my question.
Screenshot of my game
I am making a game in swing it is starting to become something :) you can see it here.
I have good performance but i want to get the best possible performance with swing so can you give me some performance tips for making games in swing?
If someone would be kind enough to criticize my code (I'm fifteen so i don't have a teacher or anything so I would like to know if I am writing crap) then you can download the source here.
Thank you
P.S: I' m serious i know that slick2d uses opengl, that swing wasn't made for games so please don't try to convert me, i will use a library for my next project don't worry ;)

Quick things come to my mind is, use of VolatileImage in place of BufferedImage can be better. BufferedImage will not provide hardware accelarated operations, but VolatileImage can provide.
But you have to investigate this.
See: Java : VolatileImage slower than BufferedImage
Or google "BufferedImage vs VolatileImage"
Further I suggest reading on like GraphicsDevice, GraphicsConfiguartion to work with images compatible with device.
One more tip: If your game has frequently used time consuming math operations like cos, sin, sqrt, you may cache results of this operations when game loads. Caching means - store results of math operations in data structures like arrays or maps, when game need to perform these operations, game can lookup values of operations without performing again.

Related

Using windowbuilder to learn swing. A bad idea? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I started to play arround with windowbuilder and I have already built a few basic GUI programs. However, I was wondering if I'm doing myself a disservice by learning swing this way instead of building everything myself, without using any plugins? I do have a good understanding of what goes into building the whole GUI, but still, what's your opinion on the matter?
I usually give the same example. You can't teach someone to use a calculator before teaching him how to sum. I think it's important for you to get familiarized with most of the swing components and try to grasp the basics about them so you can code them easily.
WindowBuilder is very helpful for complex designs and components, but I think you should first know the fundamentals before switching to WindowBuilder. Many people would disagree with me because that extension makes life a lot easier but it's really important to know the basics in case someday you want to work somewhere without WindowBuilder or NetBeans, or even if you want to understand the code that the program is making for you.
So, to sum up: You can install WindowBuilder and use it to learn but keep in mind you may not get some VERY useful knowledge with this method. Also, analyze the code thoroughly to understand it and try not to over-use the tool.
I would recommend writing initially with your hands. After all, WindowBuilder and similar tools are designed to speed up development, use them if you understand what is inside. All the best!

What programming language to use for developing visual novel type game? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I would like start to build my own framwork to make visual novel type games. I am fairly confident in using Java.
Please tell me if it is a good choice to use it to for that kinda development. I want to use fullHD images, hq animation to display and I'm not sure if java is a good choice or not, but in the other hand i would like my games to run on any platform.
If is not the good choice for my requierments please tell me what programming language should I use.
Thanks for taking your time to help sincerely and sorry for my english.
Well, I think you can do this with most 3rd generation languages. For this type of game you could do several things depending on how much control you want. If you want to render quads (2d planes with images on them) and texts, and be able to transform them and apply your own shader programs for visual effects take a look at slick utils and the light weight java game library (LWJGL), an openGL implementation.
just using java native code will limit you significantly, as well as just using native classes in other languages.
it not really the language you should search for but more the frameworks. I worked with LWJGL and it was quite hard to learn. but in my opinion easier to learn than serious frameworks within a language such as c or c++

Java Programming real objects [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I never programmed real objects. I only did some JFrame, Swing and a little bit of game Engines.
I've always wondered, is it possible to program real objects? like a web camera Board? if yes, then how? Especially a web camera, how is that possible?
I have a school project about web cameras and I thought on and said to myself, why not program the board to make it more advanced!
The main question is: Can I program real life objects (like a webcam), and how?
Yes you can. Unfortunately Java is not well suited for this task (for various reasons).
I would suggest you buy an arduino set and learn what it can do regarding controlling devices and receiving input from sensors, so you know more about what is possible.
I think you mean if it is possible to create a firmware or program embedded systems in Java. Answering this question is not so easy. If the producer of the "real object" provides you a way, how to create a programs for that real object, then yes, it is possible, but this is quite rare. You can't just buy the cheapest web camera and write your own firmware. Google up some programmable devices, that you can fiddle with or if you are just curious and this is you hobby, then make an application for a smartphone. Android devices are programmed in Java and you can play also with the camera.

How to programm the AI for a chess game [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am considering making a chess game for android apps. The only thing I don't know how to do is write code for the opponent AI or how it even works.
Do I have to write the code for the AI from scratch or are there packages that I can just implement?
There are many ways you can go. Most of the chess engines rely on approved chess theortical investigations and have quiet a large bibliothek of them to evalute to first 12 moves of a game. This is why some of them get pretty confused when doing unusual things, which was a winnig approach in the older generations of chess enginges.
Bascially it's the taks of encoding the rules of the game and then, of course, find an algorithm to find the best solutions.
For that again there are many different approaches, linear optimization is one but has its impacts as the game is rather complex and solving systems of linear inequations is both a memory and cpu consumig task and cannot be multithreaded properly.
Another approach is the use of genetic algorythms, which imho fits best to this kind of problem domain as it's encoding of the rules and possible strategies into the genstructer and rating the individuals of an population in the fitness function.
This can be spread of multiple threads pretty well, but this approach also has its own impacts, as the required population size will be high which obviously again is a memory consumption.
There are existing solutions such as the metioned http://stockfishchess.org/download/ stockfishchess engine or http://cinnamonchess.altervista.org/, which provide an android api and many resources on the web about how to do it are also available in the net such as http://chessprogramming.wikispaces.com/Chess+for+Android (a starting point).
Also you could try to port an existing chess engine for linux to android such as
http://cinnamonchess.altervista.org/ which should't be to heavy as android is Linux -based and the android replacement for glibc is mostly compatible.
Or you could try a Java chess engine such as https://github.com/albertoruibal/carballo and port it to android, too. Just search for open source chess engine and you will find many existing solutions.
"The only thing " is pretty amusing in this case, because the main part of writing a chess game is to write the Ai for it.
Another approach could be to use a http://de.wikipedia.org/wiki/Schachserver chess server and communicate with it so that your player can connect to the net and play agains others.

GWT code OR GWT Designer? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am new to GWT. I have a question. Which way is better to learn/use GWT programming. Either to learn using GWT by writing code for creating user interface OR through GWT Designer? I am also aking this question in the context of good programming practices & industry requirements.
I agree that code is much better. Plus later on when you want to do more fine tuning of your UI, exact position up to the pixel level for example, I have found that the Designer is not very easy for aligning widgets. You will need to get down to the code level anyway to do so.
Another benefit like it was already mentioned is you will get a better understanding of what is going on.
In my opinion it's better to learn to code it from scratch. That way you get a much better understanding of what the underlying code does. Because you'll also have to consider supporting the GUI you develop as well. And if you use a designer, while it's a lot quicker, it'll add it's own code to it, and it may not be pure GWT code.
So in my opinion, code it by hand, sure it'll take longer, but you'll understand it better, and be able to support it. And it'll be another great skill to your bow.
I use a mixed solution. Designer for main blocks and code for details...
I would suggest to start with coding rather than the designer. From a learning point of view, coding gives more information regarding how you can use and extend functionality.
Client side scripting involves good styling, alignment which you will understand once you work via the code and scripts.

Categories

Resources