• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

The Madman

File I/O routines are a pain in the ***

5 posts in this topic

OK, stupid math error, it was SUPPOSED to be 315 bytes but I made a stupid error. But that still doesn't explain WHY its gives out garbage.

------------------
That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA! :D :D :D

0

Share this post


Link to post
Share on other sites
Here's your problem buddy....you increment the pointer...and *poof* you expect it to remember where it begins??? Well, unless you left out part of you code, you obviously do. You have to make sure you keep track of where the array begins and ends if you are going to increment it in this fashion. If you were to use array[i], you would have this problem, but since you're doing array++, unless you back it up, it's gone forever... Now, I could be wrong here, and missed something, but there really isn't enough unified code to tell. (At least not for me.) Sorry if this doesn't help.
0

Share this post


Link to post
Share on other sites
Sorry, I left out some words. If you use array[i], you do NOT have to keep track of the beginning. Otherwise, make a char *temp, and just have temp = array...then when you're done stuffing it, array = temp, and you're back to the beginning.
0

Share this post


Link to post
Share on other sites
OK, here's the deal. I got it working pretty good, but I modified it a bit. First I used the old C file routines, like fopen(). Second, I cleaned up the code and I modified it so that it doesn't use pointers but deals with the arrays themselves. Finally, I got it to work except for a slight matter. Here's the main() function:

code:
// Main function
void main(void)
{
char choice=0;
char x,y;
char array[316];
char newline=0;
CLevelDesc level;

level.LoadLevelFile();

// Now get the user's input
while(choice!='3')
{
// Now get what the heck the user wants to do
printf("\nEnter 1 for reading, 2 for writing, and 3 to quit.\n");
choice=getche();
printf("\n");

switch(choice)
{
case '2':
for(y=0; y {
newline++;
array[((y*CELL_X)+x)+newline-1]='\n';
printf("\n");
for(x=0; x {
array[((y*CELL_X)+x)+newline-1]=getche();
}
} // end for
array[315]='\n';
level.WriteNewLevel(array);
break;
} // end switch
}// end while

level.UnloadFile();
} // end main()


It works pretty well, except on the first line instead of getting a newline two of the lines. Here is the first line


ddddddddddddddddddddÖdddddddddddddddddddd


Could someone help me?

------------------
That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA!

[This message has been edited by The Madman (edited August 08, 1999).]

0

Share this post


Link to post
Share on other sites
Hi people, I'm working on my next game already. I'm trying to use Andre's strategy in Underworld and not use hard coded data, but use an external file that contains the level data. Unfortunately, this is giving me pain. I am using my preferred file loading functions, the mmio type. I am also using introductory C++/OOP, as I'm using classes. Here's my code for loading the array with data and stuffing it into the class function:
switch(choice)
{
case '2':
for(y=0; y{
for(x=0; x{
*array=getche();
array++;
}
*array='\r';
array++;
printf("\n");
} // end for
level.WriteNewLevel(array);
break;
} // end switch

The variable "array" is a character pointer with all the space needed allocated. Here's the class function, WriteNewLevel():

void CLevelDesc::WriteNewLevel(char *data)
{
// go to the end of the file
mmioSeek(file, 0, SEEK_END);

// Write the data to file
mmioWrite(file,data,(CELL_X+1)*(CELL_Y));
}

The problem is that my file now holds 315 letters of garbage where it should hold 320 letters of whatever I specify (right now I'm trying to use just one character that is solid throughout the file.) Could someone help me?

------------------
That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA! :D :D :D

0

Share this post


Link to post
Share on other sites
Are you getting the ...dddÖddd... effect on every line, or just the first?

Can't really see what your code is doing, because it's trying to parse it for html... look at your for loops

When you're showing code in your posts, a good suggestion is:

<code>
code goes here...
</code>

White Fire

0

Share this post


Link to post
Share on other sites