Hello,
(I think I've made a similar post somewhere, but I've been digging around the interwebs for a while and still found nothing so here I am).
I've been looking into really efficient ways to make games (and also just learn how to make one from memory and sheer knowledge) and the method I have come across seems super efficient and I really want to use it but I really struggle with loading images as it requires some of the most complicated bitwise operation code I've ever seen...
Here the main theory of how I intend to make games:
- Make a basic window. Use BufferStrategy and BufferedImage in order to get a black screen going.
- Start pixel modification (use DataBufferInt) and draw the direct modification of pixels to the screen.
- Get other things going such as an FPS counter.
- Get a 256x256 image with a grid pattern on it (just think of a big chess board except the squares are all one color and you can only see the grid lines) and load images that are in the individual squares (or tiles).
- Draw whatever you like to the squares and then load the squares as you like.
I've seen it done before, but they used all of these bitwise operators it confused the hell out of me. Anyone have a good explanation? Every link I try I can't understand it well enough.
And if this post has just confused people then I will edit.
6 replies to this topic
#1
Posted 23 January 2012 - 03:13 AM
|
|
|
#2
Posted 23 January 2012 - 04:04 AM
Why would you need bit operators for images to load? That's just ImageIO.read(...)
Check this example, it some kind of chess with only towers cause I was too lazy to download more images :P
[ATTACH]4514[/ATTACH]
It doesn't do anything, just makes the GUI, loads the tower image, puts them at their positions and each tile of the grid is drawn using the Graphics class (eg. no image).
Btw, I just throw exceptions all over the place - You may want to use try catch ;)
Check this example, it some kind of chess with only towers cause I was too lazy to download more images :P
[ATTACH]4514[/ATTACH]
It doesn't do anything, just makes the GUI, loads the tower image, puts them at their positions and each tile of the grid is drawn using the Graphics class (eg. no image).
Btw, I just throw exceptions all over the place - You may want to use try catch ;)
Attached Files
#3
Posted 23 January 2012 - 04:42 AM
wim DC said:
Why would you need bit operators for images to load? That's just ImageIO.read(...)
Check this example, it some kind of chess with only towers cause I was too lazy to download more images :P
[ATTACH]4514[/ATTACH]
It doesn't do anything, just makes the GUI, loads the tower image, puts them at their positions and each tile of the grid is drawn using the Graphics class (eg. no image).
Btw, I just throw exceptions all over the place - You may want to use try catch ;)
Check this example, it some kind of chess with only towers cause I was too lazy to download more images :P
[ATTACH]4514[/ATTACH]
It doesn't do anything, just makes the GUI, loads the tower image, puts them at their positions and each tile of the grid is drawn using the Graphics class (eg. no image).
Btw, I just throw exceptions all over the place - You may want to use try catch ;)
No, I mean, you have one image (yeah, which would be loaded via ImageIO.read(...)) which would consist of a grid, with tiles and then you would draw things in each of the squares and then load the squares at will. That would be a really efficient way of loading images because you would only have one image.
I'll try to upload an image to try and show you what I mean.
Also, what is "0xff" in Java?
#4
Posted 23 January 2012 - 04:43 AM
Can you post the code with the bitwise operators to show what you are talking about.
That is a number written in hexadecimal format. You are used to numbers written in base 10: 255.
You use hexadecimal numbers to make it easier to see which bits are turned on in a number.
Quote
what is "0xff" in Java?
You use hexadecimal numbers to make it easier to see which bits are turned on in a number.
#5
Posted 23 January 2012 - 05:53 AM
Norm said:
Can you post the code with the bitwise operators to show what you are talking about.
That is a number written in hexadecimal format. You are used to numbers written in base 10: 255.
You use hexadecimal numbers to make it easier to see which bits are turned on in a number.
That is a number written in hexadecimal format. You are used to numbers written in base 10: 255.
You use hexadecimal numbers to make it easier to see which bits are turned on in a number.
Thank you, I'll start looking into hex numbers in Java aswell.
As for the code, I was looking at Notch coding Minicraft (for the Ludum Dare 22 competition) and the way he was loading stuff from a grid looked really efficient.
Here's the link for the video where he plays with pixels and stuff: realnotch - Ludum Dare 22. The theme is "Alone". Making a Harvest Moon game.
If you can make any sense of the bitwise stuff he is doing, I'd be very interested in knowing xD
#6
Posted 23 January 2012 - 05:55 AM
If you have any questions about bitwise stuff, please copy the code here and ask your questions about it.
#7
Posted 23 January 2012 - 03:13 PM
Why try to make your programs as efficient as possible? I usually design/write a program, then later try make it more efficient (if it needs to be).
As long as you make a good preliminary design, you should be able to easily swap out inefficient code with efficient code later on in the program's life without affecting other portions of your program.
If you're curious to learn about bitwise operations, I'd just do a search for it on your favorite search engine.
If you're really want to get into efficiency, I might choose a language like C++ over Java. Why? Because you can interact more with memory from C++.
As long as you make a good preliminary design, you should be able to easily swap out inefficient code with efficient code later on in the program's life without affecting other portions of your program.
If you're curious to learn about bitwise operations, I'd just do a search for it on your favorite search engine.
If you're really want to get into efficiency, I might choose a language like C++ over Java. Why? Because you can interact more with memory from C++.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top










