domingo, 11 de noviembre de 2018

Sons of Camelot: Avoid screen from shutting off


If you don't touch screen mobile, screen will shut off.
If screen goes black in the middle of classical introduction scene, it' not the best start.

¿Solutión? Here

Summarizing, add this code in an object (creation code) at the beginning of the game:

if os_type == os_android || os_type == os_ios
   {
   os_powersave_enable(false);
   }

If only using Android, remove IOS part.

domingo, 14 de octubre de 2018

Sons of Camelot: Depth Tables


  • By default in GM all objects have depth 0.
  • In case of equal depth, "tie", the newest object will prevail and will be above the oldest one.
  • Positive depth numbers mean distant instances,  far away from player (in other words, "into" the screen). 
  • Negative depth numbers mean near instances, close to the player (in other words, "de profundidad indican instancia cercana al jugador (es decir, más cerca, towards "outside" the screen).
  • Then virtual controls (phones,tablets), must be great negative numbers (i.e. -9999).

You can choose depth when "building" the object, in CREATE event, in this case depth won't change during the game. Also you can choose depth in every frame, in STEP event, in this case every frame depth will be updated, it's changed during the game.

We use to match depth with the negative "y" value, as in physical screen, y=0 means upper part, when going down "y" increases. That way, if an object it's moving up and down, depth is going also up and down:
In that case put in STEP event:   depth = -y;



Example: Depth table, 1st round "Blood Bros" game
OBJECTDEPTH
Cart, Common enemy (away)-200
Buildings-225
Common enemy-250
Horse enemy, Bonus-300
Rolling barrel-325
Enemy bullets-350
Explosion-375
Player bullets-400
Player sight-450
Barrel (defense player)-475
Player-500
Interface (lifes, score, etc)-9999

In this table, I choose depth values to show you how it works. That means values could start i.e. in 0 and going up to higher negative values. Also could start in 0 for interface and then going up in positive values, higher when further away. Doesn't matter your system.

To understand this, let's see this "Blood Bros" screen:

 

Players (indian and cowboy) are closest to us, closest to physical screen, that means, its depth values are higher "negative " values than the other objects. In my table -9999.
After them, we found defense barrels and players sights. Its depth value are lower then the player one, but "lower" then the others.  In my table -500.
After them, enemies and Rolling barrel.
After them.... etc

Above all (including players) is the Interface, in this case no problem, is just an arcade game, no on-screen controls. but in a mobile game, controls must have the highest negative value.

I choose a similar table for "Sons of Camelot".


Biggest diference: on screen controls. Depth = -9999.
Same for score, life.

Luego tenemos el player, los enemigos comunes, los edificios, los arqueros, las carretas,etc.
Por detrás del todo (valores de profundidad más positivos), las nubes, que se mueven sobre el fondo.

Sons of Camelot: Making a "Blood Bros" clon

I’m going to make a clone of the great TAD Corporation game in 1990, “Blood Bros.
This is a small analysis of said game. The idea is to see how it works to replicate the mechanics in my own game.

BLOOD BROS FACTS!


Movement of the character and the sight in Blood Bros:

  • The player moves the character in the horizontal plane (joystick) and it moves always at the same speed for one side or the other. 
  • When the player moves the character (joystick), the sight moves at the same time almost twice the speed of the player. That is, moving the character involves moving the sights. 
  • When the player presses the firing button, the character does NOT move and fire.
  • If the player presses shot + movement (joystick), the sight moves while shooting, leaving the character immobile. 
  • The player can dodge while moving, the sight remains still while dodging. 
  • When the player fires, the shots instantly reach the target (there are no bullets crossing the screen). 
  • The player can throw bombs at the target, the bombs cross the screen until they reach the target. 
  • The sight stops at the edges of the screen when it reaches them and stops. 
  • The player stops at the edges of the screen, there is no scroll.

Characters in Blood Bros

  • Player 1 always plays with the cowboy and Player 2 always plays the Indian.
  • Both are virtually the same except for the character and sigth sprite. 
  • The player dies when 1 bullet / bomb touches him, there are no “energy points”. 
  • In the original game the player takes about 3.5 seconds to travel the screen from side to side, the look takes about 2 seconds to travel the screen from side to side (I would say it is almost twice the speed), we will try to follow those speeds.


Stages in Blood Bros

  • The stage has several planes where the enemies move. There are nearby enemies (larger), medium distance and in the distance (smaller). 
  • The scenario is composed of several buildings / destructible buildings that can be in different planes. These buildings / constructions have, therefore, a quantity of “life”, when the buildings / constructions are destroyed they stop making parapet to the enemies that pass behind. The form of destruction is always the same, they crumble down. 
  • There are also objects (such as barrels or rocks), just in front of the players, who act as cover / defense, they can also be destroyed and simply destroyed when they are destroyed. 
  • To advance to next screnn, the player must destroy a certain number of enemies (FOE indicator in the game), the indicator increases each time it is killed.


Weapons, bonuses, bombs in Blood Bros

  • There are 3 weapons, the basic one (always carried by the player), the shotgun and the rifle. The sight becomes bigger when catching a better weapon and it shoots faster and the shots do more damage. 
  • The weapons last a limited time. 
  • When killing enemies they can release bonuses (they give points when picking them up or when they are shot while falling). 
  • When shooting certain NPCs (pigs, dancers, etc.) they can drop weapons or bombs (they are picked up when passing over them or being shot while falling).NPCs do not die, they simply run away.


Enemies and their behavior in Blood Bros


All the screens, except those of Boss, have established a CYCLE of enemies that is repeated. That is, if we have not finished the phase when the cycle ends, the cycle begins again. For example, suppose the cycle lasts 60 seconds:


sec 3: 3 enemies come out on the right, go to the center, shoot and leave on the left
sec 8: 3 enemies leave on the roof of a building, shoot, and flee
sec 12: 1 pig-bonus comes out from left to right

sec 55: 1 enemy left on horseback, throws a bomb by taking 1/3 screen
sec 60 END OF CYCLE (THEREFORE WE BEGIN TO START !!!)
sec 63: 3 enemies come out on the right, go to the center, shoot and leave on the left
sec 68: 3 enemies come out on the roof of a building, shoot, and flee
sec 72: 1 bonus pig comes out from left to right

etc etc


Technical data

The original resolution of the game is 256 × 224 px .

Can be player by 1 or 2 persons at same time.


What is the FOE bar (enemies)

FOE means enemy,

To advance to next screen, the player has to fill the FOE bar. This is achieved by killing enemies.
Usually any enemy will add 5 points of FOE with his death.
The bar will be filled when you get 200 or more points. At that moment all enemies die and advance to next screen.

Sons of Camelot: Initial approach

Before programming, some things have to be considered.
As part of an already-existing game, mechanisc are already established, part of our work is already done.
But as this game is supposed to be played on mobile devices, it's a must to add on screen controls.

This game will be done using Game Maker (abreviatted GM).
I'm using GM Studio v1.4, all comments refer to this version.
Right now, new version just hits the streets (GM 2), lot of things changed then this new version is not suitable for my explanations.


Splitting Screen for the game, User interface and Ads



First approach:

Blood Bross resolution is 256x224px. My first idea was use 640x480px (later I change my mind).

But at this moment I thoght this:

  • Main region is game region (see yellow region just below), will be 640x400px. This doesn't respect original resolution or screen ratio, no problem, we are making new game, not a port.
    Just below: 
  • Left part (red zone): joystick, 150x80px. 
  • Center part (blue): ad banner, 300x80px. 
  • Right part (purple): 2 buttons (roll, fire), 190x80px. 

Above purple region we put transparent button, will be the third one (bomb/special attack), we can't put in purple region, no space for it.

Ad banner needs to be smaller than blue region, to avoid unexpected ads stopping game. If this happens to often, users will stop playing.

Changes in approach:

Finally not going to use 640x480px. I will use "pixel-art" sprites in my game, so I will use low resolution, 320x240px.

Different screen regions for game, joystick, buttons will be keep, but I will not use ad region. Instead I will add ads only when starting new level.


Collision mask

A collision mask is a graphic that represents the "sensitive" area of an object (a player, an enemy, a wall, a door). The mask doesn't need to be as the sprite of the object, in fact it's better not to be same (reason below).

Mask is used to detect when 2 objects hit, i.e. player is hit by a bullet, or maybe player hits a wall.

By default GM uses bigger rectangular shape that contains sprite, that means mask could be really big if sprite has irregular shape, also lot of computer power waste, much better to use simple shape as rectangle or ellipse to avoid any problem related to irregular shape of sprite.

I.e. for this skeleton sprite


this is GM automatic collision mask (in dark grey):


Player Mask

We will use a manual mask, rectangular shape, from head to knee in example.


For each object's sprite, for running, walking,etc we will follow above recomendations, changing maybe mask position but not mask size.

Only exception from my game will be roll sprite, it will be only 1 single pixel  at the character's feet. That way when rolling player is almost invulnerable and then player won't be stuck in a wall.

If we use different masks for different player conditions (running, idle, hurt, roll, etc) could change player condition just when player is i.e. near a wall, then is mask change to a bigger one, player will be stuck there.


Other masks: Enemies and Furniture

Automatic mask. But take care about we will discuss next.


When NOT use automatic mask

We have this kind of sprite (Big skeleton):


By default collision mask is a big rectangle, that means transparent parts are also included, then if player hits transparent parts is hurting skeleton. 

To avoid this, I changed mask shape to ellipse:





Player: Power Ups

Player by default has a basic fire, can upgrade by getting power ups, just for limited time.

We will follow original game strategy:
  • Basic fire: slow fire, hits 1 life. 
  • Upgrade fire: fast fire, hits 3 life each time. Lasts around 10 seconds.


Player: from Bombs to Special attack

Blood Bros player could use bombs, its number were limited, but can get additional bombs during the game.

In "Sons of Camelot" I will change bombs for special attacks. Better for fantastic middle ages game.


Scores, bonus and shop

Score in original game:

  • 100 points, common enemy.
  • 100 points, horse enemy.
  • 1000 points, destroy small forniture.
  • 5000 points, destroy wagons, also bonus item will fly and player has to get it before dissapear.
  • 5000 ó 10000 points, destroy big forniture (like houses), also bonus item will fly and player has to get it before dissapear.
  • etc

In "Sons of Camelot" we will follow this, bonus items will fly and player has to get it before dissapear, they will remain 2 seconds on the floor.

But also we will add coins to game. We can recollect them, and use them to buy things in the shop (like additional power ups, special attacks and lives).


Font

We will use font “D3 Rabbitmapism” very nice and looks as the original font.

To find this font, I use MAME to get original font screen (MAME  / load game / F4 / ENTER / move in game until fint font screen). Then I capture this screen:
Now we take some characters (i.e. from A to G) with any bitmap program like Windows Paint, save file. Then browse to http://www.whatfontis.com/  and it will search for similar fonts, we look for “free” fonts only.

After that, I installed this font to Windows (right click + install).
Then use program Bitmap Font Creator (link) and create new font using this parameters:

Font tab

Size: 20
Bold-Italic-Antialias: NO
Fill mode:Gradient, Gradiente1 ( color1: white, color2: RGB(202,203,177) )

Special Effects tab
Outline: 2
Shadow: NO

Then go to Generate Tab and push Go! (new file in desk named output.png). Check file size  H x W (we will use later).

Go to GM make new font, Edit Sprite+File/Create from Stripe.

Import Menu: We write down there are 95 images, 10 each row.
To put "Image width" e "image height" we divide file size by 10.

In example, if file size is 940x770px, then we use 94px y 77px in GM .

Very important, delete first image (must be an empty image in white).
Now we can use this font, adding this in new font object:

fntBitmapFont = font_add_sprite(test2, ord("!"), 1, 1);
draw_set_font(fntBitmapFont);
draw_text_color(150,150, "Texto de ejemplo", c_white, c_white, c_white, c_white,1);

VERY IMPORTANT: This font object must be added to any ROOM we use it.