Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (532)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Can someone tell me how to make a screen that I can use!  (Read 877 times)
0 Members and 1 Guest are viewing this topic.
Offline samdeman22

Junior Member


Projects: 1



« Posted 2013-06-14 16:18:22 »

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

If in doubt go flat out - Collin McRae
Offline van noctar

Senior Newbie


Medals: 1



« Reply #1 - Posted 2013-06-14 16:31:43 »

Hello Smiley What language is used? What libraries?
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #2 - Posted 2013-06-14 23:12:22 »

What language is used?

This website is called java-gaming.org

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2013-06-15 14:08:31 »

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

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

Offline van noctar

Senior Newbie


Medals: 1



« Reply #4 - Posted 2013-06-16 18:56:47 »


Xd, it's alright!
Offline Troncoso

JGO Coder


Medals: 20



« Reply #5 - Posted 2013-06-16 19:46:36 »

It sounds like you need to follow some tutorials before just jumping into the development...
Offline samdeman22

Junior Member


Projects: 1



« Reply #6 - Posted 2013-06-17 19:10:41 »

I have, for quite some bloody time I might add.  Clueless  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.

If in doubt go flat out - Collin McRae
Offline Saiqal

Senior Newbie





« Reply #7 - Posted 2013-06-17 19:22:43 »

I could explain to you what I know, but I'm bot that good at explanations  Grin
So I'll give to a link to where I learned that stuff back then : it's from the newboston (an excellent teacher)
http://www.youtube.com/course?list=ECFE2CE09D83EE3E28
have a look at the GUI tutorials. Starting from about lesson 51.
Offline samdeman22

Junior Member


Projects: 1



« Reply #8 - Posted 2013-06-17 19:51:28 »

Maybe I should be more helpful to you all.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
      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
  • = 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 Smiley

If in doubt go flat out - Collin McRae
Offline samdeman22

Junior Member


Projects: 1



« Reply #9 - Posted 2013-06-17 19:52:50 »

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)

If in doubt go flat out - Collin McRae
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Saiqal

Senior Newbie





« Reply #10 - Posted 2013-06-17 20:09:08 »

What you had originally is a two-dimensional array. What you want to do is :
1  
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
1  
pixels1dim[j * width + i] = color;

instead of
1  
pixels1dim[i][j] = color;

and again in the second loop
1  
2  
3  
4  
5  
6  
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];
   }
}
Offline samdeman22

Junior Member


Projects: 1



« Reply #11 - Posted 2013-06-17 20:24:58 »

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

If in doubt go flat out - Collin McRae
Offline samdeman22

Junior Member


Projects: 1



« Reply #12 - Posted 2013-06-17 20:55:52 »

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!  Grin

If in doubt go flat out - Collin McRae
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #13 - Posted 2013-06-17 21:35:45 »

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.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (16 views)
2014-07-24 01:59:36

Riven (16 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (16 views)
2014-07-23 20:56:16

ctomni231 (43 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!