Hello there, if you are here, it's probably because you're interested in making HTML5 Games, or you're just curious about our game engine.
So here is the github's link, more descriptions/tutorials are coming soon.
The "How to" will help you to start, and the documentation is available but not complete, feel free to help me complete it :).
If you are new in JavaScript (or if you only develop in jQuery), I strongly recommend you check out the RequireJS before you start a new project using our Dream-Engine. You can also use the standalone version of our engine that only requires RequireJS to load the engine.
Also, if you don't know Grunt, you might want to check it out beforehands (even if you can do it later), as this will save you a lot of time to build your own game (especially games on specific platforms).
There is currently the API Documentation website, and I'm filling it. Regardless, the code is well commented (Prioritizing on what you will use for sure). There is also the "How To" which is a great way to get started with the Engine.
Documentation is made for those who want get closer with the engine, or those who want contribute.
The Games featured below were made using the Dream-Engine.
If you made anything using the Dream Engine (a game, a prototype etc...), make sure to let us know so we can feature it here !
(If your project is getting displayed here we will need a 256px icon, a short presentation (in English if you can) that will be visible
on this page as well as a longer one that will be displayed if someone presses "About" on your Project's card.)
If you wish to contact us: Facebook - Twitter - contact[ at ]dreamirl[ dot ]com
Do you wish to try the Dream-Engine ? If yes, you've come to the right place !
With this short guide, you will be able to do things like "this" with no efforts.
We are going to use GameObjects (with inheritance), SpriteRenderer, TextRenderer, Keyboard and Mouse Inputs, Gamepad API, Audio, and after all this, compile it all using Grunt.
By the end of this tutorial, you should be able to make your own complete game !
Let's get started then ?
Copy all the sample "kill-bubble" in a new folder (being the least filled folder that we have at our disposal). This is my personal way of doing it : "(grunt file, _dev folder, release folder)"
You can of course do as you please, but keep in mind that I will be using this template for the rest of the tutorial.
We are only going to work on the "_dev" so if you see something such as "Go in the 'js' folder", it will actually be "_dev/js".
Rename the balls.html if you want to as well as the title or other meta. You don't have to rename css/js files.
Just open js/custom/Game.js to remove the current game. Remove from line 17 to 144 and add this :
If you encounter any difficulties or need additional help, you can check out the full sample source code available in your "samples" directory (little-shmup).
First thing you need to do is have your Inputs, Images and Audios that you're going to need in your game.
Copy the folders "audio" and "img" from "sample/little-shmup/_dev" in your "_dev" folder.
Then go into your "js/datas" folder and open "audiosList.js", in the audioList's array, you have to put all the musics and FXs that you wish to use :
This is quite simple so I won't be spending any more time on it. Now proceed to open dictionary.js, if you want to use more languages, you can do so, but I personnaly made it for English and French so far.
Now set "imagesDatas.js", it's a little bit more complicated because there are a lot of options, and that's also where we'll be setting up the Quality Settings.
Now, let's take a look at some details.
First of all, screenSizes are the different available qualities for your game, you can have just one set up, but if you want to see your game running well on mobiles, and have a great quality on a desktop computer, you should use this file to make more than one.
You provide a width (w) and a height (h) and you can set a specific path for the quality. This path will be a suffix to the folderName.
There is also another way to have a good customization without having to resize all of your images and creating new folders. You can simply set the "notRatio" to true, and this will make it so that the given sizes aren't the native sizes for your images (this feature is currently work in progress).
You shoudln't set a path that's different from the original quality AND notRatio to true at the same time, because when you set notRatio, the Engine resizes images with the ratio from the original size and replace it with the current one.
conceptionSizeIndex is the index in the screenSizes array which you build the game in (in this case, we'll make the game based on 1000*1080, so it's 0, but I could put 1 if I were to make the game based on 666*720. You can of course set this as your default size, BUT you cannot set notRatio on the conceptionSizeIndex size attribute if you want to modify the conceptionSize. You have to manually resize all of your images for the given ratio.
folderName is the path to images
Now, to load your images, you have to use an array with the following parameters:
Now, open inputsDatas.js, and you can see that this is another file that has many options. Try to do this as best as you can, trust me, it will save you a lot of trouble later on :)
Some details, here it's not an array because we want a name on our inputs.
I explain with the "fire" input.
Wooo, that's all for customizing the engine. As I said it's a little bit complicated, and sometimes it boring, but honestly this will save you to much time later
We are making a shmup game, so we need a Player class, Enemy, and Bullet.
The Dreamengine is made to think inherits and architecture, I'm going to show you how to do this and make something maintainable.
So create in the js/custom folder the files Player.js Enemy.js Bullet.js and datas.js (to save all the custom datas of the game).
Add these files in js/files.js like this (there is already Game and customLoop):
Now we write the basic needs for RequireJS. In each custom files created write this
In js/custom/datas.js remove 'datas', 'DREAM_ENGINE' (and the same args in the function), datas don't need anybody, it's just json datas, and replace myFunction by datas = {} (it's not a function!)
In Player.js and Enemy.js add 'Bullet' in the define array and Bullet in function's arguments
The Game.js will create the player, the Enemies and he need the datas to know what to do. So add these files in the Game.js define (as we do it before) you should have this at the beginning of your Game.js
Ok we are ready start
Before write Player or Enemy, we have to write the basics to see the engine running without problems (if you forget images, or do a mistake it'll not load).
We already wrote an empty Game.init and Game.start function. If you look in main.js you can see that we give at the engine theses functions.
In fact when the engine is ready it initialize dictionary, Inputs, ImageManager, SystemDetection (by default it's web only, we'll see this later), and load the loader (you need a loader.png in the base path you given) and when this loader is loaded, the engine call your init function than you gift before.
At this moment the engine start load custom Images and you should see the Dreamirl's loader.
When the engine finished to load it call your start function.
So in the init function, you can set some parameters (like debug), create Scenes or Renders but you can't make GameObjects using images here, you have to do this in the start function
The init is short:
Add on the top the used sizes, we will need it to place the player, enemies, and if we change it it's only here. The size is the conceptionSizeIndex in the imagesDatas.
With this you have the Render, the Scene and the Camera.
If you did well, you should get a blue screen after the loading by launching the html in your browser.
Before starting custom classes, we can already write a part of the start function by making the menu (very simple menu), in the Game.start (before the setTimeout, always before) add:
I commented the code but, as resume:
At this point you could see than we can already make a simple button plugin's with GameObjects, I'll do it when the Gui will be ready.
You can think "why we don't used the GUI", and the reason is simple. I'm refactoring this part of the engine.
But we will be able to use the GameObjects or DOM, so if you like this method (or to append GUI on a GameObject directly) this will work.
Okay if you launch the html file you should have a button "Play" in the middle of the screen (if you click you'll get an error obviously we didn't created the startGame function)
Important first step with the engine. Classe's inheritance.
I didn't make a "extend" method, I don't like that, you provide an object as constructor, you use "this" inside methods but not inside the constructor, and btw you can't make private methods because you are inside a json object.
Go in Player.js and replace the content by this, we can directly set custom attributes
We created a customized GameObject, first we call the GameObject, then you can write your attributes and methods inside the function or add them later in the prototype.
At the end, we make the rest of inheritance by setting the prototype, redirecting to the good constructor, and the super (to GameObject).
After this you can set prototyped method.
Create the Player and add it to the scene in Game.start before setTimeout (I won't say it next time :p)
Wooow, but that's not exciting yet.
Go back to Player.js, we are going to make it moving and firing!
Add inside the main Player scope (because we use private attributes) the following methods.
And in the prototype
Ok, it's time to explain.
We added the method init (when restart game), checkPos (provide area limits), checkInputs (to control the ship), fire, flip (little feature to dodge by flipping on the sides), createGui (create heart and restart button), getDamage in the prototype and updateAxes in the prototype.
Each function seems to me eloquent so I don't explain each of them (you knows JavaScript) but I explain the engine features.
Look at the last lines in the main scope:
In the createGui method we created a button "restartBtn" that trigger a restart event on mouseUp.
Bind this in Game.js (after player creation) and disable the player to don't see it in the menu:
Set the fxs volume lower
At this point you can't see your "Player" because we didn't create the "StartGame "function, add after the start function.
Nothing exceptional here, we just used the music manager, and cleaned the scene by parsing all gameObjects by checking the tag (we have to create Bullet and Enemy still )
Now if you refresh and click "Play" you can control your ship with keyboard (and with gamepad if you use chrome)
tadaaam....
Hum ok, we have some work to do to finish this "game". But you already know lot of things to be able to make games.
In the following lines, we are going to see how to delete objects, it's very simple (just call askToKill) and make some collisions detection.
To move a bullet, we will use the "addAutomatism" method. It's very powerfull to make some IA, and you can remove an automatism (with removeAutomatism(name)) so you can make an automatism call an other, destroying himself, etc... it's like "co-routine" in C# but more easy and "clean" in my opinion :)
If the object is disabled, all automatisms are also disabled.
If you want you can copy Enemy.js, Bullet.js and datas.js from the custom folder in the sample, and this will be finished, anyway I paste code here.
Open Bullet.js
Open Enemy.js
As you can see in Enemy and Bullet, to test a collision, we call CollisionSystem and the needed method (here circleCollision) returning a boolean true if there is a collision and false if not.
This is not physics, trigger only, but enough for a Shoot'em up (and for lot of games).
In the Game.js at the end we add:
And to make it work, don't forget to add it in the customLoop.js
The customLoop is like an automatism but it's general. Not for a specific object.
In the most cases, I didn't use the gameLoop because I do all my stuff with automatism
In datas.js we create datas enemies, and datas waves. You can copy directly datas.js from the original sample
Here you have a great base to make a shoot'em up.
It's easy to make it better, some ideas if you want:
Hope this was useful, and it was giving you a good sketch about the engine possibilities and methodologies.
If I made mistakes please report it on Twitter/Fb/Reddit.
Good code and Have fun
Nothing is most simple, get npm modules (look package.json) and launch:
If you want add platforms, do as the same as I already do in compileSettings.json (and you have to create the customized files fot the platform, look in _dev/js/platforms/w8)