New to coding, Help with text adventure

Advice on general approaches or feasibility and discussions about game design

Re: New to coding, Help with text adventure

Postby dctsystems » Mon Aug 11, 2014 5:50 pm

you're going to run out of ram _REALLY_ quick, with this approach. Not only does the Arduino have very limited RAM (2k) but the way it handles strings means that all those strings get copied into RAM start up. You've got enough RAM for about 300 words!

It's also going to get really tedious typing out all those println's every time you need to edit the game. Instead you should place the text and room connections on the SD card. Then someone can create the map completely separately from the game engine. You then just read and display the text file a line at a time when you enter the room. Changing a rooms decription just means editing a file in the SD card.

http://www.sniff.org.uk/2014/05/text-ad ... sniff.html
http://www.sniff.org.uk/2014/07/text-ad ... art-2.html

I did something similar in Sniff a month or two ago. Sniff runs great on the Gamebuino, though these examples will need modifying to work, as they assume a full Unix file system, and probably blow the Arduino's Ram. They should give you a place to start though.
dctsystems
 
Posts: 8
Joined: Sun Aug 03, 2014 2:56 pm

Re: New to coding, Help with text adventure

Postby Joder921 » Mon Aug 11, 2014 7:34 pm

dctsystems wrote:you're going to run out of ram _REALLY_ quick, with this approach. Not only does the Arduino have very limited RAM (2k) but the way it handles strings means that all those strings get copied into RAM start up. You've got enough RAM for about 300 words!

It's also going to get really tedious typing out all those println's every time you need to edit the game. Instead you should place the text and room connections on the SD card. Then someone can create the map completely separately from the game engine. You then just read and display the text file a line at a time when you enter the room. Changing a rooms decription just means editing a file in the SD card.

http://www.sniff.org.uk/2014/05/text-ad ... sniff.html
http://www.sniff.org.uk/2014/07/text-ad ... art-2.html

I did something similar in Sniff a month or two ago. Sniff runs great on the Gamebuino, though these examples will need modifying to work, as they assume a full Unix file system, and probably blow the Arduino's Ram. They should give you a place to start though.

I am confused by what you said. Rooms? What? I hope you know this is not going to be a dungeon text adventure, where all you do is go into different rooms. There are no visuals, just text. But is this true that the way I have it set up, I wouldn't be able to do much text?

On a different note,
The main reason I came here is to ask how would I have the gamebuino print out different facing triangles/arrows before each option? Is it possible for me to pull some of the arrows or triangles that are in the keyboard function into the text? I think i am going to go the way where you just have to push the directional buttons to chooses 1 of 4 options.
Thank you all :D
User avatar
Joder921
 
Posts: 41
Joined: Mon Apr 14, 2014 10:51 pm
Location: USA

Re: New to coding, Help with text adventure

Postby dctsystems » Mon Aug 11, 2014 9:42 pm

By "rooms" I mean what you're calling "areas". Room is just text adventure speak for a discreet area. Whatever you call them, they need to come from SD card (it is possible to avoid copying them to RAM, and use them directly from ROM using the PROGMEM directive, but that only buys you a bit more wriggle room - SD card is the way to go)

You can get arrows by printing out non-alpha characters. Check the source to the Gambuiono fonts, and you'll see it defines all sorts of arrows and other shapes for the characters 0-31
dctsystems
 
Posts: 8
Joined: Sun Aug 03, 2014 2:56 pm

Re: New to coding, Help with text adventure

Postby AntonyPrince » Mon Aug 11, 2014 10:29 pm

I know what you mean with the memory. Right after I posted that, I added one more "area" and started getting Out Of Memory errors in the emulator. Not a very good approach. As was mentioned, storing the text to SD would be the only viable option here. I abandoned the text adventure project in favor of something that relies more on dynamically generated data. I started trying to store the strings in PROGMEM, but there was a flaw in the way I was doing it because every time I tried to access a string from PROGMEM, it just printed garbage to the screen. Learning is part of the adventure!
User avatar
AntonyPrince
 
Posts: 21
Joined: Thu Aug 07, 2014 1:07 am
Location: Virginia, United States

Re: New to coding, Help with text adventure

Postby dctsystems » Mon Aug 11, 2014 11:11 pm

you need to convert the ROM pointer to a regular pointer using pgm_read_byte
dctsystems
 
Posts: 8
Joined: Sun Aug 03, 2014 2:56 pm

Re: New to coding, Help with text adventure

Postby Joder921 » Mon Aug 11, 2014 11:20 pm

Alright, so I found out that the up triangle is 30, down triangle is 31, left triangle is 17, and right is 16. How do i go about displaying these characters? What would the command be? Also what is pgm_read_byte? Is that a thing that i have to #define?
User avatar
Joder921
 
Posts: 41
Joined: Mon Apr 14, 2014 10:51 pm
Location: USA

Re: New to coding, Help with text adventure

Postby Jolly » Tue Aug 12, 2014 7:03 am

You can display them with drawChar:
Code: Select all
gb.display.drawChar(x, y, char, size);

// for example:
gb.display.drawChar(x + 1 ,y+1, 0x30, 1);


How did you find out the numbers for the triangles? The character map here says something different: viewtopic.php?f=12&t=477

Or did I miss an update? o_O
Jolly
 
Posts: 40
Joined: Fri Jul 25, 2014 9:07 pm
Location: Germany

Re: New to coding, Help with text adventure

Postby rodot » Tue Aug 12, 2014 7:22 am

That's because he's telling the value in octal radix, so your can directly insert them in print(). For examples:
Code: Select all
gb.display.print(F("\25Accept"));

Will print *A button symbol*Accept
I have to redo this character map with octal values to make it easier to use.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Previous

Return to Project Guidance & Game development

Who is online

Users browsing this forum: No registered users and 6 guests