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 (533)
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  
  How to create a simple encoder and decoder?  (Read 1975 times)
0 Members and 1 Guest are viewing this topic.
Offline Thsotus

Senior Newbie





« Posted 2010-10-06 12:38:46 »

Hey guys, I've been posting many, MANY threads on this forum, but I'd like to ask another question:

How do I make an encoder for my game and decoder, or rather, how do I read, write, and encode files?

I want to make this as my key for Twin Days, my personal gaming project to create a text-based adventure written in Java.
As there is a lot of dialogue in an adventure game, is there a way I can store lines and strings inside of a text file, then have my program read it, decode it according to a switch block, then store it inside an array or variable in my program?  I don't want to increase the file size by coding all of the dialogue in Java.

By the way, I also want to create an encoder program that will take text and numbers and create a text file that I can decode into the game. 
I thought about doing this through using a counter to count the line number I would need to import next.  I would run this method every time I imported a line.  After importing the line (which will be a string of encoded characters, of, let's say, eph, then turn it all back one character, which will make the word "dog"), I would uncode the code and store it as a line in an array list.  After using it, I would release it from the array list.

This seems very complicated to me.  How do I even write a file, and how do I read it according to line?
How do I create a string-driven switch statement block?



Hey!  Visit the blog (and current home website) for my studios,
Thsotus Games, http://thsotusgames.wordpress.com/.

My current and most recent project is called "Twin Days."
Offline gouessej
« Reply #1 - Posted 2010-10-06 12:42:03 »

Hi!

Look at XMLEncoder/XMLDecoder (they are in the Java SDK) or a third party API called "Rebirth" might do a better job. Have you tried to use the binary serialization (Java beans, Serializable, etc...)?

Offline Thsotus

Senior Newbie





« Reply #2 - Posted 2010-10-06 13:06:36 »

I have no idea what you are talking about, sadly.

Hey!  Visit the blog (and current home website) for my studios,
Thsotus Games, http://thsotusgames.wordpress.com/.

My current and most recent project is called "Twin Days."
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #3 - Posted 2010-10-06 13:15:43 »

Beginner questions are welcome, but you must spend some effort helping yourself before others will want to spend their effort helping you:
http://tinyurl.com/3xhsclw

Offline cylab

JGO Ninja


Medals: 38



« Reply #4 - Posted 2010-10-06 13:26:33 »

Look at XMLEncoder/XMLDecoder (they are in the Java SDK) or a third party API called "Rebirth" might do a better job. Have you tried to use the binary serialization (Java beans, Serializable, etc...)?
I have no idea what you are talking about, sadly.

There is a lot of stuff already in the standard java installation for you to use. See http://download.oracle.com/javase/6/docs/index.html whats available for you to use out of the box. Everything is (more or less) nicely documented: http://download.oracle.com/javase/6/docs/api/index.html. Programming in java partly the the challenge to find out what's already there and how to use it.

And again, read more tutorials (or books) Grin

Go to The Official Java Tutorials, read and understand at least

- Getting started
- Learning the Java Language
- Essential Java Classes
- Collections

Don't fight this kind of advice. While it might look that we are just replying "Hey noob, just STFU and RTFM", we are really trying to help you! A base understanding of the language and its concepts is mandatory to get you anywhere.

There is no shortcut to this - really - we've been there - all of us!!!

Mathias - I Know What [you] Did Last Summer!
Offline Thsotus

Senior Newbie





« Reply #5 - Posted 2010-10-07 05:15:11 »

The thing is, I don't understand the official tutorials.  This is why I'm asking here--the tutorials jump ahead too fast.

Hey!  Visit the blog (and current home website) for my studios,
Thsotus Games, http://thsotusgames.wordpress.com/.

My current and most recent project is called "Twin Days."
Offline cylab

JGO Ninja


Medals: 38



« Reply #6 - Posted 2010-10-07 10:57:32 »

The thing is, I don't understand the official tutorials.  This is why I'm asking here--the tutorials jump ahead too fast.

Hmm, IMHO they are quite good. Are you sure you aren't jumping ahead too fast?

Mathias - I Know What [you] Did Last Summer!
Offline Thsotus

Senior Newbie





« Reply #7 - Posted 2010-10-07 11:42:30 »

Perhaps I am.

Hey!  Visit the blog (and current home website) for my studios,
Thsotus Games, http://thsotusgames.wordpress.com/.

My current and most recent project is called "Twin Days."
Offline cylab

JGO Ninja


Medals: 38



« Reply #8 - Posted 2010-10-07 13:31:49 »

Learning programming is a tedious task at first. But don't get impatient. Once you reach a certain level, stuff suddenly falls into places and you have one aha experience after another.  Cheesy

You should make sure, you understand the tutorial you are currently at completely before advancing to the next. To get you an idea of the effort you need to spend: take yourself one week per tutorial, starting with "Getting Started". If there is something in there you don't get, try to work it out first (by asking here or googling around), before you start the next.

After working through the four tutorials (equals about month of learning), you are pretty much at a level were you can start stuff on your own without getting stuck all the time. This is much more fun, since you are actually getting something done.  Roll Eyes

Mathias - I Know What [you] Did Last Summer!
Offline dime

Senior Newbie





« Reply #9 - Posted 2010-10-07 13:36:49 »


You might want to take a look at this for ideas:
http://www.flamewind.com/programs.html

It's a conversation editor for a NWN 2.  It outputs to XML.

I don't know the structure of your program, but you might be able to use that to create all the text via a nice GUI program.  Save it in XML and that is half your battle right there.

The other half would be writing an XML reader to pull in the data to your game.
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 (18 views)
2014-07-24 01:59:36

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

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

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

ctomni231 (45 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!