Just out of interest how would you go about coding/scripting a story line for a role playing game? Similar to Final Fantasy or Zelda.
Printable View
Just out of interest how would you go about coding/scripting a story line for a role playing game? Similar to Final Fantasy or Zelda.
That depends on how you want your engine to work.
Personally, I would include a "scripting language" in the map file, which instructed the engine to perform camera movements, change viewports, etc. Things like NPC dialog would be stored in each NPC you create in the map file also.. and these would be loaded with each NPC you allocate at runtime.
chem
Well the game consists of several map files, the map file so far includes the required tile files and what the tile will be at each location. + any overlays such as rocks/pots.Quote:
Originally Posted by chemicalNova
But for instance if you had some guards blocking an entrance/exit and you must perform a task such as speaking to another NPC to remove the guards how would the engine know if the guards were to be loaded or not.
For quests such as that, you would have a global list of "variable names" and "variable values" (like a map in C++ for example). This list would be saved in the save game, and checked when a map loads.
For example.
Pretend you have two arrays, one called g_varNames, and one called g_varValues (a list would be better so you can dynamically 'resize' it). g_varNames[0] contains "MAP1_DOOR_GUARDS", and g_varValues[0] contains "0" (or an integer value of 0.. whatever you're using).
If, on another map, you complete the quest that removes those guards, you set g_varValues[0] to "1" (or 1).
Then, when you reload the map with the guards, you check what global variables it uses, and if they are set to be true (the variable names the map uses can be stored as strings in the map file). If the quest hasn't been completed, display the guards, if it has, don't display them.
If a quest is completed on the same map as the guards are on.. its simply a matter of setting the global variable value to 1, and removing those guards from the enemy list (I assume you have a list of enemies per-map setup).
chem
Since you might be facing a massive amount of space, object and npc attributes, you might want to look into sparse arrays to conserve memory usage.. http://www.vb-helper.com/tut2.htm .. A task like this can easily get out of hand if you employ sloppy logic, but can also be done very efficiently with a little craftiness.. Zelda is a great example.. I love that series in 8bit Nintendo.. Funny thing is, if someone were to attempt to recreate it on a modern pc using poor technique, they may easily run out of resources.. I hope you keep posting your progress even if you don't perceive a problem because collabritive thought will almost certainly improve your efficiency
Chem:
Thanks for the advice.
Trigger:
:) I can imagine it getting out of hand easily. Most of the time I've spent on the game is not adding new depths such as attacks, enemies and levitation but re-writing code. Deciding how to implement the game is the hardest bit, the area editor is giving me a hard time recently. I eventually decided to have an area editor class which inherits from the main area class but adds functions to change the tiles/wav/overlays/moving tiles. Creating the character system will be the next issue and hooking than into the attack system. I'm thinking 1 base class then several inherited classes for each monster.
If you know any C# I'd be glad of any help. Zelda "Links awakening" was my inspiration, started the game again recently just because it rocks :).
I'm _fairly_ good with C#.. so any help you may need just ask :p How are you writing the engine? DirectX? Or are you getting nice and dirty with bitmap pointers and such?
chem
Cool thanks, I will send you the source when the tile engine is complete and tidy. Yes it's bitmap based, I thought learning direct X was over the top for a game style that can run on a Nintendo game boy from 7 years ago. I figured if coded well modern day computers shouldn't have any problems :).
I should be able to finish the tile engine beginning of July due to exams on at the moment.
By help do you mean help with the coding of the game or just with how it should coded? Either will be awesome.
The basics of the game are it's like final fantasy 1 / Zelda but the main character is a penguin who can cast magic. He can launch fire balls at the moment but someone pointed out to me it would be better for him to launch icicles :). If you want to know anymore ask, and I will PM you the other details I've outlined.
Final fantasy 2!!!!:
http://www.vbforums.com/images/ieimages/2007/06/1.png
Final fantasy 4!!!!:
http://www.warmech.net/special/awards/bestgame-ff4.gif
Thanks,
Rich.
Nice idea. I assume you're using Bitmap pointers instead of the default drawing methods of a Bitmap? If not, you might want to look into that for speed.
chem
I honestly don't think graphics efficiency is an issue worth too much concern given the game type as long as he's not redrawing the entire screen on every action, its the looping he needs to watch.. Better is better though, and if you got time to learn..
While that is true, if he ends up rendering a lot of effects for different character "abilities", even just a large amount of small sprites, the GDI+ functions available to a Bitmap object can really lower framerates.
chem
I was just using the graphics object, I will look into bitmap pointers. Better to have a decent engine since the game is all about effects :). Hopefully the GIMP will do me proud.
Depends what you mean by redrawn. The bitmap I use to draw on is assigned to a picture boxes image property and the picture box is invalidated every game loop. (the paint method of the picture box makes up the loop, and is capped at 100 loops per second) When the character moves the tiles directly underneath them are redrawn and the character is drawn on top, these changes are reflected next game loop.
I have the will to learn, but the time, depends on the difficulty.
I might type you up an example of Bitmap pointers. I'll show you just how quick they are.. I can perform a "Solarize" effect on a Bitmap with a huge width and height (a Digital camera image.. around 1600*1200), almost instantly.
chem
Ok, here it is..
Just add that to a project, create a pictureBox (leave it named pictureBox1), and put a huge image in there. The image I tested it on was 2304x1728 (a digital camera picture). It took less than a second to do the effect.. less than half if my in-brain timer works well :p (I didn't actually benchmark it :)).
chem
Thanks for the example!Quote:
Originally Posted by chemicalNova
Wow, that is fast though I don't understand why it is faster than using the built in functions.
So if i wanted to draw 1 image onto another I would do something like:
I will write a custom bitmap class with all the methods I need, + the solarize effect is pretty cool will be great for the ice beam attack. The ice beam attack will exhaust the players magic source so it wont be used often.Code:
convert both bitmaps to bitmap data;
set the pointer to the starting position, the place where the image is to be drawn.
loop through the image to be drawn and set the pixels of the image that is being drawn onto equal to the pixels in the image to be drawn.
'if the image needs transparency then if the pixel = pink or some colour ignore it.
The game area is only 512 by 512 consisting of 32,32 tiles. Should run fast enough :).
After your example and my last post I decided to have a go:
works a treat.Code:
private void button2_Click(object sender, EventArgs e)
{
drawImage(40, 40, (Bitmap)pictureBox2.Image, (Bitmap)pictureBox1.Image, Color.Blue);
}
//will draw one image on top of another.
//No error checking so far. Simple for test to see if the image to be drawn falls out side the image to be drawn onto.
//X position of image to be drawn on top of other image
//Y position of image to be drawn on top of other image
//toBitmap - image to be drawn on
//fromBitmap - image to be drawn
//trans - colour to ignore
private unsafe void drawImage(int X, int Y, Bitmap fromBmp, Bitmap toBmp, Color trans)
{
BitmapData toBmpd = toBmp.LockBits(new Rectangle(0, 0, toBmp.Width, toBmp.Height),
ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb);
BitmapData fromBmpd = fromBmp.LockBits(new Rectangle(0, 0, fromBmp.Width, fromBmp.Height),
ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb);
int* toPointer = (int*)toBmpd.Scan0.ToPointer();
int dy = fromBmpd.Width;
int* fromPointer = (int*)fromBmpd.Scan0.ToPointer();
int toWidth = toBmp.Width;
(toPointer) += X + (Y * toWidth);
for (int y = 0; y < fromBmpd.Height; y++)
{
for (int x = 0; x < fromBmpd.Width; x++)
{
if( !((*(fromPointer + (y * dy) + x))==trans.ToArgb()))
{
*(toPointer + ((y * toWidth)) + x) = *(fromPointer + (y * dy) + x);
}
}
}
toBmp.UnlockBits(toBmpd);
fromBmp.UnlockBits(fromBmpd);
pictureBox1.Refresh();
}
Great :)
I'm currently working on a Framework for future projects I decide to take up. It'll be tile based with smooth scrolling etc.. and everything will be drawn using pointers :)
chem
Now that is useful, the majority of apps now need some kind of scroll feature. Hopefully in a few months I will have something cool to show you! Thanks for all the advice guys.Quote:
Originally Posted by chemicalNova