Results 1 to 20 of 20
Like Tree1Likes
  • 1 Post By Norm

Thread: Java 2.D Game, place image on to JPanel or JFrame

  1. #1
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Lightbulb Java 2.D Game, place image on to JPanel or JFrame

    Hello Again!

    So I'm making my 2.5D Java game, and instead of just copying all code from youtube tutorials, etc, I want to somehow use my own methods of drawing map tiles. There's a software called RPG Maker XP, and I'd like to inherit many features it has, for example, every tile can be above the player, below the player or where the player can't pass through it, the tile has 4 different gates, north, east, south, west, which basically mean that if one gate is blocked, you can't come from that side into the tile.

    It also has not just grass tiles adjacent to water tiles, for example, placing grass and water in the middle with create visually appealing and asthetic borders between the grass and water tiles, so a miniture slide as if the water was deeper than the grass, and this is mostly visible on the north side, because the game is 2.5D, meaning you are seeing everything in an angle between birds eye view, directly above the character and looking directly to the horizon, for example maybe 45 degrees, in-between perhaps? Although, all of this isn't simulated, instead drawn of how it shoud look.

    The game will consist of offsets, a camera moving around following the player, and when the player stands near an edge of the map, the camera stands still whereas the player can still move until the edge rechead. This game can also have animations, let's say an explosion? There are text-boxes, basically RPG Maker XP. It's a ruby programming language based RPG 2.D game maker, I'd like to make a java version of it, but my own version, where I can understand everything and use it very efficiently.

    I don't need an actually Editor as in like RPG Maker XP has, but it wouldn't be a problem if it had. I don't want anyone to write the entire script, unless they don't mind at all, but then if that was so I'd need explanations of how almost everything works. I'd just like people to explain and/or give code of features that exist in RPG Maker XP, but are in java. So like, let's say you know how to make a quest? Then I'd be very thankful for you to share the code for it, and explain how it works. I'm not requesting for the whole thing, I just need help with making some of these-like features.

    Thanks
    Augustas

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,269
    Rep Power
    6

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    A whole story, yet I don't see a single question and especially not anything that might be answered in a Java forum.

    If you want all that, you'll have to learn Java, learn basic trigonometry math and learn the theory behind 2D graphics. And then apply the knowledge to build your wish. It is going to take time and lots of effort.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Quote Originally Posted by gimbal2 View Post
    A whole story, yet I don't see a single question and especially not anything that might be answered in a Java forum.

    If you want all that, you'll have to learn Java, learn basic trigonometry math and learn the theory behind 2D graphics. And then apply the knowledge to build your wish. It is going to take time and lots of effort.
    Ermm, I know java, I've learnt it, all basic terminology, I also know java math, what I really want to do is literally build my own version of JFrame, but in this forum specifically I just want people to share with me their RPG 2D game feature mechanics. For example, if you know how to make a quest? I would be thankful if you'd share your understanding of how it works, and perhaps even show a code example.

    As for the JFrame, I don't know how to make a Window, a canvas, a frame without using any java swings, utils or awts. I also want to make my own version of Graphics, so I can draw pixels, lines, rectangles, fill rectangles, all of these features, also name my window. My own version, I want to do so, so I don't have to learn the possible mechanics of JFrame, but make my own system that I can edit any time I want, my own utils, awts, swings, that I can edit and use, improve, and I will fully understand them.

    My own sort of like APIs

    You don't have to ask questions for people to reply to a forum, e.g.: please say what you think. That isn't a question type, but you still answer to it.
    Last edited by augustas656; 04-07-2014 at 04:10 PM.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    How many years do you plan to spend on this project?
    Can you write OS specific code to get to the places in the OS that support windows?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,269
    Rep Power
    6

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    I don't think I've ever seen anyone misunderstand their problem domain as much as I've seen here. You may have learned the language but you know exactly nothing about software engineering.

    At this point I fail completely, I know of no way how I can have a chance of making you understand just how wrong you are. So I guess pretend I didn't say anything.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Why would you want to develop you own set of API's when the JDK comes with such a rich set of them. And also, what exactly is "java math?"

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Maybe I got everyone confused, I want to make my own version of JFrame and JPanel, I will learn anything that I need to learn. There's a game, that I believe most of you know, called Minecraft, and it doesn't use JFrame, it uses it's own type engine. My game is going to be 2D but I want to have most of everything made from scratch. So like even if my game is really lag inefficient, I still, would like to make my own version of JFrame.

    With this, I'd also like to look at the code WITIHN the the JFrame class(es). So I can read the code, I would like to learn it, understand it, so I can make my own type engine. As I said, and I will repeat, it can be very laggy and incompact, but it's literally my first java game, and if I need to learn anything before that, you can mention it, or may find it myself.

    I have learnt Java Unit 1 from mybringback youtube tutorials, up to like 3/5s, because the rest is all about JFrame and other types of script, which I want to make my own kind of engine. For example, there's a java util I think it's called Arrays, and for sorting arrays, it literally uses an already integrated feature of java, the sort function. I might be wrong but that's what I've read, so from my understanding I just want to make my own engine from scratch to the highest extent possible.

    I know it's very bad because I'm a beginner and this stuff, although I haven't finished the java tutorials, but I want to just be able to create a window and read images from a resource folder, and draw them in any place that I want. These images would accept alpha (transperancy), and the RGB colours. I could create layers, and put these images and also be able to draw pixels and lines and shapes of any colours anywhere I want. And this is literally all I need.

    I want to do something like this because many tutorials I find, they all consist of literally 90% of code that you literally have to copy, the only thing that you can do is change the name of the variables. For me to use anything I need to fully understand it, which means if I'm using a java util, it's very frustrating for me not to read the code of that util, but a problem is I don't know where to find the code for those utils, swings and awts.

    I had great difficulty finding this code for java libraries. So I thought I'll just make my own, and I don't mind learning how to do that, but I just don't want to literally copy and paste from tutorials, and I want to understand how everything in those libraries works. I'll explain anything else that you will ask me in this thread.

    EDIT: This post's name is about using JPanel and JFrame, but I changed my mind, and I think it's not too bad to continue what I think in the same thread, if no? I'll make my own thread, again. But again, learning how to use JPanel and JFrame might help me make my own versions of them, so, why not continue on the same topic?

    Quote Originally Posted by gimbal2 View Post
    I don't think I've ever seen anyone misunderstand their problem domain as much as I've seen here. You may have learned the language but you know exactly nothing about software engineering.

    At this point I fail completely, I know of no way how I can have a chance of making you understand just how wrong you are. So I guess pretend I didn't say anything.
    Earlier today, I thought just like the Java Array liberary's array.sort function is an extension of java code, where it just uses the java sort function, the same way JFrame is just an extension for java code, using lines of code to make a window, code that all of exists in the same programming language. And I believe from what I heard I was very wrong, so from this point, I'll learn software engineering If I have to, just point me in the right direction.
    Last edited by augustas656; 04-07-2014 at 06:45 PM.

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Which java classes will you use for building blocks for your classes?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    You're talking about a game engine and a JFrame in the same context. The JFrame is just a display component. It has very little to do with the underlying aspects of any game logic. And I have found Java with Swing to be very responsive in just about everything I have written involving graphics.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  10. #10
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Yes, what I mean by game engine, and as I said make my own.
    Making my own engine is literally the same thing as making my own JFrame part of my code based on what Jim said.

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Quote Originally Posted by augustas656 View Post
    Making my own engine is literally the same thing as making my own JFrame part of my code based on what Jim said.
    That is not what I said. I said that they are unrelated.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Quote Originally Posted by jim829 View Post
    That is not what I said. I said that they are unrelated.

    Regards,
    Jim
    Okay, as simple as it gets, I want to make my own java 2D game engine, which includes... (a part of is...) my own version of JFrame.

  13. #13
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Okay, that's great! Have fun. BTW.

    JFrame is about 1000 lines of code and comments. It extends Frame.
    Frame is about 1300 lines of code and comments. It extends Window.
    Window is about 4000 lines of code and comments. It extends Container.
    Container is about 5000 lines of code and comments. It extends Component
    Component is about 10000 lines of code and comments.

    And that does not include all the various UI and Look and feel stuff and other ancillary classes and methods it
    depends on. So at what point in the hierarchy are you planning to enter the fray?

    Regards,
    Jim
    Last edited by jim829; 04-07-2014 at 10:23 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  14. #14
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Quote Originally Posted by jim829 View Post
    Okay, that's great! Have fun. BTW.

    JFrame is about 1000 lines of code and comments. It extends Frame.
    Frame is about 1300 lines of code and comments. It extends Window.
    Window is about 4000 lines of code and comments. It extends Container.
    Container is about 5000 lines of code and comments. It extends Component
    Component is about 10000 lines of code and comments.

    And that does not include all the various UI and Look and feel stuff and other ancillary classes and methods it
    depends on. So at what point in the hierarchy are you planning to enter the fray?

    Regards,
    Jim
    In that case, instead of rewritting the engine, I'll now have to read those lines of CODE, and find methods and classes that are relevant and work in-conjuction to give me a window. Also, why does my Graphics getWidth() & getHeight() are 10 higher than the specified height and width, so I setSize(640, 480), and also made a BufferedImage with 640 and 480 as width and height, and when I done the Graphics setup I also mentioned 640, 480, and inside my render class, I type getWidth() it's 650, and getHeight() it prints out 490. ??????

  15. #15
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    I can't answer that specific question. But if you have a JPanel in your JFrame and set the JFrame size, that includes the borders of the JFrame. So the panel will be reduced by the frame insets. Then if you size your bufferedImage to that of the JFrame, you won't have enough room. So size your JPanel with setPreferredSize and add it to the JFrame. Then size you bufferedImage to the size of the JPanel. Don't forget to do a frame.pack() after adding the panel.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  16. #16
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    [Java] package pack.script.game; import java.awt.BorderLayout; import java.awt.Canv - Pastebin.com
    Here's my entire code, I'm kind of confused, and I'm new to components, so please explain further, and I still want to use this code, just reform some areas to make it how you explained. Thanks, if you may..

  17. #17
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    I suggest you start with the Java tutorials mentioned in my signature. If you are confused with components then you will have a very difficult time writing your own version of a frame or anything involving graphics or GUI's. Take it step by step.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  18. #18
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Do you know of a place where I can ask simple questions and/or get responses to my java errors that I post really fast? I mean you know of a place where I can put my errored java code and it will be responded to faster than Java Forums? perhaps? I registered here mainly because of that... P: It's definetelly faster than minecraftforums off-topic section, xD.

  19. #19
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    You could hire a programmer to get personal service.
    augustas656 likes this.
    If you don't understand my response, don't ignore it, ask a question.

  20. #20
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    169
    Rep Power
    1

    Default Re: Java 2.D Game, place image on to JPanel or JFrame

    Quote Originally Posted by Norm View Post
    You could hire a programmer to get personal service.
    That would be awesome, I might do that later. Thanks.

Similar Threads

  1. Replies: 3
    Last Post: 12-08-2013, 10:28 PM
  2. Replies: 1
    Last Post: 10-09-2013, 11:01 AM
  3. Not able to place image in Jframe in proper manner
    By rahul405804 in forum AWT / Swing
    Replies: 1
    Last Post: 05-07-2012, 09:38 PM
  4. Need help posting Image into JFrame in Shooter game
    By Noctis Lucis Caelum in forum Java Gaming
    Replies: 1
    Last Post: 01-25-2011, 12:18 AM
  5. How to place components on JPanel
    By deshprateek in forum AWT / Swing
    Replies: 1
    Last Post: 02-22-2009, 06:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •