Skip to content

Commit 3a730b2

Browse files
committed
more docs
1 parent 9fa882f commit 3a730b2

File tree

2 files changed

+109
-16
lines changed

2 files changed

+109
-16
lines changed

README.md

Lines changed: 109 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,21 @@ It uses [GBDK 2020](https://github.com/Zal0/gbdk-2020) but expands it to give yo
77
![gif](https://raw.githubusercontent.com/Zal0/ZGB/master/doc%20files/tuto.gif) ![gif](https://github.com/Zal0/bitbitjam2016/blob/develop/bitbit3/res/marketing/screenshots/pretty.gif?raw=true) ![gif](https://github.com/Zal0/gbjam2016/raw/develop/res/marketing/gifs/fly.gif?raw=true)
88

99
## Getting started
10-
- Download the latest [release](https://github.com/Zal0/ZGB/releases)
11-
12-
- Run install.bat (this will create a new environment var ZGB_PATH pointing to %ZGB%/common)
13-
14-
- Download the [ZGB-template](https://github.com/Zal0/ZGB-template/archive/master.zip) and build it running build.bat
15-
16-
- Follow the tutorial on the [wiki](https://github.com/Zal0/ZGB/wiki) to understand the basic concepts of the engine
17-
10+
- Installing ZGB
11+
- Download the latest [release](https://github.com/Zal0/ZGB/releases)
12+
- Run install.bat (this will create a new environment var ZGB_PATH pointing to %ZGB%/common)
13+
- Creating a new project
14+
- Download the [ZGB-template](https://github.com/Zal0/ZGB-template/archive/master.zip) and build it running build.bat
15+
- Follow the tutorial on the [wiki](https://github.com/Zal0/ZGB/wiki) to understand the basic concepts of the engine
1816
- (**Optional**) Download [***Microsoft Visual Studio Community Edition***](https://www.visualstudio.com/downloads/)
1917
The [ZGB-template](https://github.com/Zal0/ZGB-template) comes with a solution customized for visual studio
2018

2119
## Documentation
2220
Check the [wiki](https://github.com/Zal0/ZGB/wiki)
2321

2422
## Support
25-
twitter: [Zal0](https://twitter.com/Zal0)
26-
27-
discord: [gbdk/zgb discord](https://discord.gg/XCbjCvqnUY)
23+
- twitter: [Zal0](https://twitter.com/Zal0)
24+
- discord: [gbdk/zgb discord](https://discord.gg/XCbjCvqnUY)
2825

2926
## Features <a name="features"></a>
3027

@@ -36,10 +33,11 @@ discord: [gbdk/zgb discord](https://discord.gg/XCbjCvqnUY)
3633
- [Sprites modes 8x8 and 8x16](#sprites-modes-8x8-and-8x16)
3734
- [Sprite animations](#sprite-animations)
3835
- [Collisions sprite vs sprite and sprite vs background](#collisions)
39-
- Almost transparent, bank management, now using bankpack
40-
- Fonts
41-
- Music support using [gbt-player](https://github.com/AntonioND/gbt-player) or [hUGETracker](https://github.com/SuperDisk/hUGETracker)
42-
- Sound Effects
36+
- [Auto Banking](#auto-banking)
37+
- [Fonts](#fonts)
38+
- [Music](#music)
39+
- Sound Effects
40+
- Game Boy Color
4341

4442
### Easy makefile support
4543

@@ -224,7 +222,7 @@ The Sprite field **anim_frame** contains the animation index if there is an anim
224222
225223
### Collisions
226224
227-
All sprites have a rectangle collider that will be used to check collisions. By default it will be defined by metasprites width and height but you can adjust it on the sprite .meta file
225+
All sprites have a rectangle collider that will be used to check collisions. By default it will be defined by the metasprites dimensions but you can adjust it on the sprite .meta file
228226
```
229227
-px 2 -py 0 -pw 12 -ph 19
230228
```
@@ -234,8 +232,103 @@ This rectangle will remain constant when the sprite is flipped
234232
235233
#### Sprite vs Background
236234
235+
First you need to declare an array (terminated in 0) indicating which tiles are considered collidables
236+
```C
237+
UINT8 collision_tiles[] = {1, 2, 3, 4, 8, 10, 0}; //In this case tiles 1, 2, 3, 4, 8 an 10 will be considered collidables
238+
```
239+
240+
Then you need to pass this array when you Init the scroll (you can have several arrays depending on the tileset you use)
241+
```C
242+
InitScroll(BANK(map), &map, collision_tiles, 0);
243+
```
244+
245+
And now, instead of directly modify the X and Y coordinates of your Sprite, you need to call TranslateSprite
246+
```C
247+
TranslateSprite(THIS, -1, 0); //Move the current sprite 1 pixel to the left checking collisions with the background
248+
```
249+
If the Sprite collides then it won't advance and TranslateSprite will return the collision tile (so you can check if there are spikes or other stuff)
250+
251+
You can also declare an array of collision tiles that will be only checked when the Sprite is moving downwards. This is very useful for platform games where the character can jump into a platform from below
252+
253+
![gif](/doc%20files/readme/coll_down.gif)
254+
237255
#### Sprite vs Sprite
238256
257+
To check if two sprites are colliding call the function CheckCollision in "Sprite.h"
258+
```C
259+
if(CheckCollision(THIS, other_sprite))
260+
{
261+
//Sprites are colliding!
262+
}
263+
```
264+
265+
### Auto Banking
266+
267+
ZGB uses [bankpack](https://bbbbbr.github.io/gbdk-2020/docs/api/docs_toolchain.html#autotoc_md79) so you don't need to worry about where to place your code or resources. Just make sure that:
268+
- **_#include "Banks/SetAutoBank.h"_** is added at the beggining of your States and Sprites
269+
- If you need to call an sprite function from another sprite, declare it **BANKED**
270+
```C
271+
void HitMe(); //WRONG!!
272+
void HitMe() BANKED; //RIGHT!
273+
```
274+
- If you receive this error after making a build:
275+
```C
276+
**2>EXEC : error : size of the buffer is too small**_
277+
```
278+
279+
You need to increment N_BANKS (must be a power of two: 2, 4, 8, 16...) in your makefile
280+
- Check the png created in the Debug/Release folder of your build to get an overview of your banks usage. For a more detailed information you can use [RomUsage](https://github.com/bbbbbr/romusage)
281+
282+
### Fonts
283+
284+
Fonts in ZGB are gbr files of **45** tiles, with uppercase characters **_A-Z 0-9 !'()-.:?_** The ZGB-Template already comes with a default font that you can customize
285+
286+
In order to print some texts in your game
287+
1. Import the font using
288+
```C
289+
#include "Print.h"
290+
IMPORT_TILES(<font filename>);
291+
```
292+
2. Init the font in the START function of your State by calling
293+
```C
294+
INIT_FONT(font, PRINT_BKG); //PRINT_BKG to draw on the background or PRINT_WIN to draw on the Window
295+
```
296+
3. Print some text using
297+
```C
298+
PRINT(0, 0, "Hello World"); //print Hello World on 0, 0
299+
```
300+
301+
You can also use **Printf** to draw some vars with %d %i &u and %s
302+
303+
You can change the target (background or window) with the var **print_target**
304+
305+
### Music
306+
307+
You can select witch music drive to use [gbt-player](https://github.com/AntonioND/gbt-player) or [hUGETracker](https://github.com/SuperDisk/hUGETracker) in the Makefile
308+
```
309+
# Music player: HUGETRACKER(default) or GBT_PLAYER
310+
MUSIC_PLAYER = GBT_PLAYER
311+
```
312+
313+
To play some music in your game
314+
- Place the .mod or .uge files in the res/music folder
315+
- Import the music with
316+
```C
317+
DECLARE_MUSIC(<music_filename>)
318+
```
319+
- Play it with
320+
```C
321+
PlayMusic(<music_filename>, LOOP)
322+
```
323+
- And Stop it with
324+
```C
325+
StopMusic(<music_filename>, LOOP)
326+
```
327+
328+
### Sound Effects
329+
330+
### Game Boy Color
331+
239332
## License
240333
241334
Released under the [MIT license](https://opensource.org/licenses/MIT)

doc files/readme/coll_down.gif

37.5 KB
Loading

0 commit comments

Comments
 (0)