Understanding Weaver Directories
To understand the organization of Weaver Directories, the best approach is creating a very simple project using Weaver. We show here how to create the simplest Weaver Game possible: an empty game that shows nothing and exits if the player presses any key.
Let's create a project called "dummy". It's easy. In a terminal, use the following command:
weaver dummy
A new directory called "dummy" will be created and inside it, you can find a lot of interesting files and directories that you can use in you game creation:
- images/ : This directory starts empty, but all the PNG images that the game will use must be stored here.
- sound/ : This directory also starts empty. All the Ogg Vorbis files for sound effects that the game will use must be placed here.
- src/game.c : This is where your game's main loop and main function will be.
- src/game.h : A header file for game.c. You should update it when you create new functions and other things in game.c.
- src/weaver/ : This is where all the Weaver Functions are stored. Usually you won't need to change anything inside this directory.
- Makefile : The Makefile is handled automatically. But if you wish, you can also change it manually.
Inside all these directories, exist a .web hidden file that can store some useful information for Weaver. Thanks for them, when you invoke Weaver from inside a Weaver Project, Weaver's behaviour is different.
For example, remember that when you were outside a directory created by Weaver and typed "weaver dummy", a new Project called "dummy" was created. But what happens when you type "weaver dummy" inside a project? Let's try it. Go to any directory inside the Weaver Project and type:
weaver dummy
This time, a new directory called "dummy" wasn't created because we already were inside a Weaver Project. What happened instead was that 2 new files (dummy.c and dummy.h were created in the src/ directory. The Makefile was also updated to countain these files.
If you try to invoke "weaver dummy" again, nothing will happen because the file "src/dummy.{c,h}" already exists. So you don't need to be afraid of erasing a file accidentally running Weaver. Almost all the Weaver commands are non-destructive. Weaver (almost) never would erase a file.
I said almost never, right? Well, if you upgrade to a newer version of weaver, the new version is able to erase some files and create others as needed to update your project to the newer version. Usually only files under "src/weaver/" are updated. To update an older project to the current version of the framework, just type "weaver ${PROJECT_PATH}", replacing "${PROJECT_PATH}" by the path where the project can be found. In our example, if you are inside the "dummy" directory, which is a weaver project, just type "weaver .".
In the first paragraph we said that we are going to create an empty game that exits when the player presses any key, right? Well, it's done. Weaver creates it automatically while creating a new project. All we need to do is compile the game. Go to the directory where there's a Makefile and type:
make
Now you can test and play the game. Enjoy it:
./dummy
If you wish to install our masterpiece, run (as root):
make install
And to uninstall, run (as root):
make uninstall
Well, this is the basic that you need to know about Weaver Directories.