Michael
Donators
Hero Member
Posts: 2166
|
|
« on: October 16, 2012, 07:56:40 PM » |
|
I found this site ( citytechinic.com) and its gives a nice tutorial on how to make a text adventure with groovy. I pretty much copied everything xD ok but exactly, do you think I am making progress? new GroovyShell().evaluate("game.with{${playerInput}}")
game.go 'north' > You go North. game.look() > You see a dagger on the ground. game.take 'dagger' > You take the dagger.
class Game { void go(dir) { println "You go $dir" }
void look() { println "You look around and see nothing." }
void take(it) { println "You take the $it" } def methodMissing(String name, args) { def funcName = ThesaurusLookup.contains(name) if (funcName) { } this.take(args[0]) } }
yes, I do know that i need to change some things. such as the defined words like "it" and much more. and I will also need to define them. G'night!
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #1 on: October 17, 2012, 02:00:27 PM » |
|
I'm up and running, I have made some changes to it: // Directions def n = 'north' def s = 'south' def e = 'east' def w = 'west' // Items def w1 = 'axe'
// Where the player types the commands. new GroovyShell().evaluate("game.with{${playerInput}}")
class Game { // Directions game.go("north") { println "You traveled $n" } game.go("south") { println "You traveled $s" } game.go("east") { println "You traveled $e" } game.go("west") { println "You traveled $w" }
// Looking game.look() { println "You see something! What, an axe? I think that would be useful." }
// Taking game.take(axe) { println "You take the $axe" } def methodMissing(String name, args) { if (['grab', 'hold'].contains(axe)) { } this.take(args[0]) } }
I will come w/ more updates.
|
|
« Last Edit: October 17, 2012, 02:04:11 PM by unnaturallife »
|
Logged
|
|
|
|
Moonkey
|
|
« Reply #2 on: October 17, 2012, 02:19:38 PM » |
|
Definitely a text adventure. Looks correct to me
|
|
|
Logged
|
Mythruna: Don't you dare read any posts I made before 2014.
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #3 on: October 17, 2012, 02:30:12 PM » |
|
i am still having a complication... i cannot compile my groovy files xD I use my cmd with this command: groovyc -sourcepath (path)
what I enter is: groovyc -sourcepath C:\Users\...\Desktop\Games
"..." indicates my username.
|
|
|
Logged
|
|
|
|
pspeed
|
|
« Reply #4 on: October 17, 2012, 02:56:28 PM » |
|
Yeah, your script looks pretty messed up. You are trying to be too fancy using complex groovy things. Stick to the basics of straight methods and bodies. (Note: it's impossible to diagnose compile errors unless we see the compile error. <-- last time I will offer that advice)
For example, all of your game.go() stuff makes no sense where it is. What is "game"? What is "go"? None of those things are defined but you might not get errors because you've implemented a methodMissing() method that will prevent errors from showing up. (ie: you are using a groovy trick to implement commands instead of just implementing them.)
I think it is a mistake to follow a groovy example of a text adventure. You should maybe find a Java version and then adapt it. They will use way fewer tricks that way and you can concentrate more on learning the coding and data structures and less on confusing groovy idioms.
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #5 on: October 17, 2012, 06:33:32 PM » |
|
My problem is that I do not believe in limits. Yes, I know I am naive about that thought. My strive is strong, but yet it is small. The key to do, is to learn. Thanks for the help Paul.
|
|
« Last Edit: October 17, 2012, 06:55:51 PM by unnaturallife »
|
Logged
|
|
|
|
Iggyjeckel
Donators
Hero Member
Posts: 510
|
|
« Reply #6 on: October 17, 2012, 06:53:35 PM » |
|
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault
Dont expect a spanish teacher to teach french to the japanese student
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #7 on: October 17, 2012, 06:56:24 PM » |
|
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault
Dont expect a spanish teacher to teach french to the japanese student
xD what does that have to do w/ the price of tea in China?
|
|
|
Logged
|
|
|
|
Iggyjeckel
Donators
Hero Member
Posts: 510
|
|
« Reply #8 on: October 17, 2012, 07:02:09 PM » |
|
Hmm nevermind you editted it out, befoe you had quotes around help, just seemed sarcastic, must have taken it wrong way
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #9 on: October 17, 2012, 07:55:44 PM » |
|
Hmm nevermind you editted it out, befoe you had quotes around help, just seemed sarcastic, must have taken it wrong way
Eh.. life has been harsh lately. I read it w/ quotes a couple times and it just seemed so rude. I know Paul is helping me as much as he can w/out too much time consumption. I remember a time when I used to be mature...
|
|
|
Logged
|
|
|
|
Moonkey
|
|
« Reply #10 on: October 17, 2012, 07:56:42 PM » |
|
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault
Dont expect a spanish teacher to teach french to the japanese student
xD what does that have to do w/ the price of tea in China? What does that have to do w/ what Iggy just said? xD Edit: Mature? Nobody is ever Mature. It's just manners that make people seem mature. Curiosity may be what killed the cat. But you aren't a cat xD
|
|
|
Logged
|
Mythruna: Don't you dare read any posts I made before 2014.
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #11 on: October 17, 2012, 08:03:34 PM » |
|
*cough* correction, if you watch Spongebob, it is "Curiosity is what salted the snail." not "Curiosity may be what killed the cat." I also found a nice site that teaches you how to make a text-based adventure game in java. Paul said to find a java version and adapt to it. so the site is.. that is a link => ...<= knil a si taht
|
|
|
Logged
|
|
|
|
BenKenobiWan
Friendly Moderator
Donators
Hero Member
Posts: 674
Jesus loves you!
|
|
« Reply #12 on: October 17, 2012, 08:05:33 PM » |
|
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault
Dont expect a spanish teacher to teach french to the japanese student
xD what does that have to do w/ the price of tea in China? What does that have to do w/ what Iggy just said? xD Edit: Mature? Nobody is ever Mature. It's just manners that make people seem mature. Curiosity may be what killed the cat. But you aren't a cat xD Nobody is perfectly mature, sure. But there are different levels of maturity. Maturity is a lot more than manners, but I don't know if this is the thread for that.
|
|
|
Logged
|
|
|
|
Moonkey
|
|
« Reply #13 on: October 17, 2012, 10:59:16 PM » |
|
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault
Dont expect a spanish teacher to teach french to the japanese student
xD what does that have to do w/ the price of tea in China? What does that have to do w/ what Iggy just said? xD Edit: Mature? Nobody is ever Mature. It's just manners that make people seem mature. Curiosity may be what killed the cat. But you aren't a cat xD Nobody is perfectly mature, sure. But there are different levels of maturity. Maturity is a lot more than manners, but I don't know if this is the thread for that. Maturity is like a cat... No it isn't... Maturity is like... Aww I'm bored. Random post for postiness.
|
|
|
Logged
|
Mythruna: Don't you dare read any posts I made before 2014.
|
|
|
|