Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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  
  a gui game engine that saves your files?  (Read 1399 times)
0 Members and 1 Guest are viewing this topic.
Offline lefnire

Senior Newbie




Java games rock!


« Posted 2005-03-22 21:16:04 »

I asked this in another post, but I don't think I expressed it very well... so now that I have time I'll try again.

I'm using borland to create a gui that will be something like RPGMaker2000.  Via widgets I will manipulate how the game looks, where sprites go, what tilesets go in which rooms, etc.  When I'm done creating my game, I want to save it as a game class that extends applet, implements runnable, etc.  I was thinking, the "save" button could save a text file that writes out all the stuff that's not varialble, like:
out.println("import java.awt.*; import java.applet.*;... public class videoGame extends...")
then I'd concatonate variables in that I changed in the gui.  When all is done, it would be saved as a text that I could just change the extension to .java and compile and go.

Anyway, the idea is stupid, but hopefully that will give you a better idea of what exactly I'm trying to do. Basically I'm trying to either save a complete java project (not just text or object data binaries) that ISN'T the java project I'm presently in (which is the gui), or manipulate a template that would have all the stuff i need for this game and I could just change the variables.  I'm dumb, and all I know about regarding template manipulation is random access, which wouldn't work because it requires that the input be the exact same length in terms of letters as the template.

Any ideas?
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2005-03-23 05:48:50 »

I'm sorry, I'm still confused as to what you're trying to do?

The generated source code would be the RPG game logic? If you just want to save some source code to a file just using a java.io.FileWriter?

It would probably be nicer if your gui saved it as a .java and compiled it for the user (this isn't tricky, its all given to you in tools.jar of the JDK install).

Sorry not to be more help,

Kev

Offline lefnire

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-03-23 18:09:02 »

That would be great if I could do that!
for the life of me i can't find info on the subject dumbed down enough for me to understand (the tools.jar that is, i couldn't figure out how to use it to save files, only to archive them).
Basically my gui will be a .java that creates a different .java (and hopefully, like you said, compiles and runs it too).  I'll use the gui to modify variables, then once the user hits "save" those variables will be inserted into a template, and that now modified template is saved as its own .java, without saving any of the gui information (except of course the modified info used in the template).
if that is indeed what tools.jar does, know of any sites or documentation on the subject?
Thanks once again kev, you are being most helpful!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2005-03-23 18:22:17 »

Ok, file writing.. assuming you have your text in a JTextField called code.

1  
2  
3  
4  
5  
String text = code.getText();

PrintStream out = new PrintStream(new FileOutputStream("code.java"));
out.print(text);
out.close();


Dumps it out to a file. Next you want to compile it, here:

http://mindprod.com/jgloss/javacexe.html

Half way down the page it starts talking about "Programmatic Invocation". The bit in particular you want is:

1  
2  
sun.tools.javac.Main comp = new sun.tools.javac.Main( System.out, null );
boolean success = comp.compile( new String [] { "HelloWorld.java"} );


You'd need tools.jar in your classpath for that to work. However, this whole thing sounds a bit ropey, you might want to consider what exactly you want to achieve and consider whether you really need to progmatically generate code?

EDIT: This might help too, http://www.javaworld.com/javatips/jw-javatip131.html

Kev

Offline lefnire

Senior Newbie




Java games rock!


« Reply #4 - Posted 2005-03-24 20:17:23 »

Kev, may the hair on your feet never fall out.  That answered my question exactly.
Offline lefnire

Senior Newbie




Java games rock!


« Reply #5 - Posted 2005-03-24 20:50:51 »

it still sounds ropey, eh?  Well, let me try one more time to explain exactly what I'm trying to do.  Don't feel obligated to find out how to do it, you answered the question exactly with that last link, and thank you very much.
Anyway, as an example if I wanted to create an applet with hundreds of components (myriads of different buttons, images, sliders, etc) then it would be MUCH easier and time saving to do that through a gui like borland Jbuilder, instead of programatically.  Similarly, I want to make a game that reuses certain classes (sprites, background, tiles, etc).  If i wanted to make a full game, it would take FOREVER to do the whole thing programatically, and it would be a tedius copy/paste/modify exercise.  So I want to make a "borland Jbuilder" so to speak, a gui that makes a separate program.  When you save your java file in jbuilder, it doesn't save it as part of jbuilder, but a completely separate .java.  Similarly, I want to use my gui.java to save a project that I could later modify called game.java.
An example is RPGMaker 2000 (http://www.gfxartist.com/features/articles/279).  in rm2k you select a sprite and drop it onto a canvas, then you select a portion of the canvas to fill with a certain tile, etc.  you specify where you're main character will start, what certain events are invoked by certain actions, etc... finally, you save your project and run it.  It's more work to begin with to actually MAKE rpgmaker 2000 than it would be to simply program a small game, but when the games start getting bigger it saves time this way.  Does that make more sense?
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2005-03-24 21:39:28 »

Sure does, its exactly what I thought you were getting at. These systems (RM2k for instance), rarely generate code since (or at least not code that anyone bothers to understand). Generally they go for a set of core object built into an engine with a dialect of one type or another that manipulates the engine.

The reason its generally done without code is so that the internals can be changed which still keeping a backwards compatibility. While this is possible using Java (since its such a wonderful language), I still maitain that you have to have a pretty strong case to justify using something like BSH, or code generation.

Kev

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.

xsi3rr4x (30 views)
2014-04-15 18:08:23

BurntPizza (27 views)
2014-04-15 03:46:01

UprightPath (42 views)
2014-04-14 17:39:50

UprightPath (24 views)
2014-04-14 17:35:47

Porlus (41 views)
2014-04-14 15:48:38

tom_mai78101 (63 views)
2014-04-10 04:04:31

BurntPizza (123 views)
2014-04-08 23:06:04

tom_mai78101 (222 views)
2014-04-05 13:34:39

trollwarrior1 (189 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!