Can someone tell me how to make a screen that I can use!

I have an overly long and complicated code that I was going to use for a game, but the first part, getting the screen to do something! Can someone show me the code for a simple screen (frame) that also renders the data given to it? If you know what I mean? If I could get this out the way I can move on and input things to the screen without hassle!

the width is 450
the height is 450 / 16 * 9

HALP

Hello :slight_smile: What language is used? What libraries?

This website is called java-gaming.org

Well, you can’t just ask to make something. It will make forum looks like fiverr without the $5 ;D

Tell what exactly your problem is. If you need template you can search it.

Xd, it’s alright!

It sounds like you need to follow some tutorials before just jumping into the development…

I have, for quite some bloody time I might add. :clue: But still I don’t want you to make it for me (if you do it is helpful though), I want a link maybe to a useful website, or more importantly… how on earth do I interact with my screen I just made, how do I put stuff on it, explanations.
thankyou.

I could explain to you what I know, but I’m bot that good at explanations ;D
So I’ll give to a link to where I learned that stuff back then : it’s from the newboston (an excellent teacher)

have a look at the GUI tutorials. Starting from about lesson 51.

Maybe I should be more helpful to you all.

		pixel = new int[height][width];
		
		//1D pixelData to 2D pixel (for cartesian coordinates)
		for (int i = 0; i < height; i++){
			for(int j = 0; j < width; j++){
				pixel[i][j] = pixelData[i*j];
			}
		}
		
		//pixel changes go here.
		pixel[30][60] = 0xCC0000;
		
		//flatten back to pixelData
		for(int i = 0; i < pixel.length;i++){
			for(int j = 0; j < pixel[i].length; j++){
				pixelData[i*j] = pixel[i][j];
			}
		}

I did a bit more, figured it out and I am able to change pixels by simply going pixelData[x] = etc. But now this has come up.

this is where my problem lies. I want to convert the 1D array from the bufferstrategy into a 2D Cartesian array (for ease of use), and then input my 2D stuff back into the 1D pixelData but you see when I change the pixel[30][60] to 0xCC0000 (or any coordinate/colour) it doesn’t work, nothing shows except the black default. I know this lies in the array but that’s where my brain shuts down on me :slight_smile:

I also want it layed out so I can put in x and y co ordinates, I think the current setup means I have to input (y, x) instead of (x, y)

What you had originally is a two-dimensional array. What you want to do is :

int[] pixels1dim = new int[width*height];

And then you were right about the for loops. But inside the for loop you will have to use the

pixels1dim[j * width + i] = color;

instead of

pixels1dim[i][j] = color;

and again in the second loop


int[] pixels1dim = new int[width * height];
for(int j = 0; j< height;j++){
	for(int i =0; i< width;i++){
		pixels1dim[j * width + i] = pixels2dim[i][j];
	}
}

wait, why am I doing the first conversion? I don’t need to do that! All I need to do is the second conversion ::slight_smile: because I don’t need to know what it looked like the render before, if you know what I mean.

Uurgh, I’m just scrapping this 2d array for now and going with the 1D. I just made a function setPixel(x, y, col) to do the whole “Cartesian” thing. thanks for the help anyway! ;D

There are a myriad of Java tutorials on the topic of drawing/rendering, including Oracle’s excellent tutorials.
The JDK also comes with sample apps demonstrating almost all of the Java2D API.

Google is your friend.