![]() |
|
|
[JAVA] Need a good tutorial link... - Printable Version +- Little Fighter Empire - Forums (https://lf-empire.de/forum) +-- Forum: General Zone (https://lf-empire.de/forum/forumdisplay.php?fid=23) +--- Forum: Programming (https://lf-empire.de/forum/forumdisplay.php?fid=50) +--- Thread: [JAVA] Need a good tutorial link... (/showthread.php?tid=5870) Pages:
1
2
|
|
[JAVA] Need a good tutorial link... - Alblaka - 12-09-2010 Now, i just hope the "No requests!" rule refers solely to LF2-sections&stuff :P Hey ho ^^ As some (actually: none) people may know, i'm studying Computer Science right now. Because the actual programming stuff is on a quite easy and basic level atm, though, i already started programming an own game in Java (yes, Java sucks, we all know. But it's the offical language for our course right now). The game is supposed to be an basic tabletop strategy game, turn-based. However, up to now it only consists of MASSES of codes, methods and a big data file (value&stats&stuff). The big problem (aka my request) is, i failed to find a useful, understandable and explaining tutorial for creating a GUI so far... I just need a few basic menus and a clickable interface (which sends the data of where the click went to a method) in-game. Anybody knows a good tutorial (site) or may even possesses a similar game as OpenSource file (usually studying other projects is always the best way to learn programming *obvious hint for people trying to learn DC*)? RE: [JAVA] Need a good tutorial link... - Xidd - 12-09-2010 java has a few libraries for guis. the tutorials on the sun/oracle website are quite good and explain the basics: http://download.oracle.com/javase/tutorial/uiswing/ you can also follow the 2D Graphics one if there are any apis ure unsure of then you can just look it up on the main javadoc thing (which is very good) http://zetcode.com/tutorials/javagamestutorial/ and some examples of specific game implemenations using the default java libs - those examples r "c written in java" type of thing... dont pick up programming style from that - stuff should be in seperate objects and not just one big long program (thats what they should be teaching u if they decided on java) swing gives you kinda sh**** preformance - but since its a turn based game and written in java (so preformance will never be ideal) i wouldnt worry abt it RE: [JAVA] Need a good tutorial link... - Alblaka - 12-09-2010 Just quickread the second link. Great tut for implementing sprites (and some other things i probably won't need right now.) The first link seems to contain some more detailes instructions on how to load datafiles into the applet. I actually solved that problem with just typing all 1000+ (no joke, took me 1 1/2 hours) into Eclipse... but to know the faster solution could be useful XD Just the Mouse-Clicking-Story left ^^' RE: [JAVA] Need a good tutorial link... - Xidd - 12-10-2010 need to do more reading and less typing ![]() look at the minesweeper example in that link, it deals with mouse stuff more info abt those 2 can be found @ http://download.oracle.com/javase/1.4.2/docs/api/java/awt/event/MouseAdapter.html & http://download.oracle.com/javase/1.4.2/docs/api/java/awt/event/MouseEvent.html gd luck with ur game RE: [JAVA] Need a good tutorial link... - Alblaka - 12-10-2010 Jup, i found some good and easy to implement codes for mouse-interaction, should work ^^ However, i'm completely stuck on the image part... It does display an image in a window now... And that's all it does. I can't get it to create multiple pictures in the same window :(
It will only display the image noted last. And sometimes, it won't display anything at all. RE: [JAVA] Need a good tutorial link... - Xidd - 12-10-2010 here is how i did it : http://pastie.org/1365778 http://pastie.org/1365780 shows how to draw images, how to crop them + implements all the mouse stuff then again its pretty bad... u shoud rly consider actually reading stuff on the official java websites i linked to (not the zed stuff). they show u properly structed stuff and not just hacked together stuff by somoene like me who hates OO programming and thinks it sucks ![]() RE: [JAVA] Need a good tutorial link... - Alblaka - 12-10-2010 Hmmm... prob is, i need the game to load the icons/graphics MULTIPLE times... with that code i need to create a new Board object after every unit-movement, wouldn't i? edit: So, further studied the code ( with these pasties you gave me): If the GUI is created, it can add ONE "Board" to the screen. This Board can draw multiple images. Which means, i need to create a GUI whenever i want the screen to refresh... which means, there will be another window created every time i want the picture to refresh... or somethign ![]() Uhm... is there an option to delete/close GUI-created frames... It gets... funny, after the 100th GUI-Screen created. Actually i'm suprised it didn't crash XD RE: [JAVA] Need a good tutorial link... - Xidd - 12-10-2010 did you read any of the tutorials ? u setup a timer which keeps calling paint, so paint gets called every 10ms or something and updates the screen ( http://zetcode.com/tutorials/javagamestutorial/movingsprites/ )or you since this is turn based and the frame isn't likely to change that freq u can just paint it when ever a change is found ( http://zetcode.com/tutorials/javagamestutorial/minesweeper/ ) u should tihnk about the structure of the program - how the data will be represented etc the way i would do it is create a class for the units then have an Array (or maybe ArrayList/LinkedList/HashMap/*insert collection here*) of all the units. all paint will do is itterate over that collection and just draw them. then the mouse handlers will be used to "move" the units - a.k.a change their x/y cord. this is probably where the majority of the logic will be located/called from RE: [JAVA] Need a good tutorial link... - Alblaka - 12-10-2010 (12-10-2010, 07:04 PM)Xidd Wrote: did you read any of the tutorials Now, my question is HOW THE HELL do i paint it every time? As far as my knoweledge goes the ONLY way to make the classes draw something is by creating a new GUI-object aka new window (which creates the image class drawing the things). The logic for moving/attack/load/unload/reload/Arty/AA is completely done, i already have list for the units as well. I could implement the drawing sequence for these units as well, but it would kill my tests because i only have a single sprite atm (though, i could probably just create multiple units of the same type using the same sprite XD). edit: another test... Am i supposed to use GUI.image-thingy.repaint()? editedit: Another look at the tutorial link I'll make the vague guess that my above theory may be correct.. the example is using repaint as well... If this seriously is the solution to the problem i'm working on for days now... i will... dunno... rage, probably. Or cheer... or cheer raging... or something similar like rage cheering. RE: [JAVA] Need a good tutorial link... - Xidd - 12-10-2010 yes... you need to call repaint(); . the first example calls it through a timer that it setupthe minesweeper one calls it every time a peice is moved |