Coding with Kotlin and Parse-SDK using Android Studio.Read More
The story of how I got into Make School Summer Academy.Read More
I was working on Agenda Digital Honduras, a social event platform. People can view coming events in Honduras, get some info like description, date, hour, place, and detailed url.
I love working with Parse, for me it's the best backend solution. I don't like the idea of sharing the App id or Client Id, so that's why I never thought on using Parse JS SDK. So I always ended up using Parse PHP. I was playing with NodeJS (cool stuff) and saw that I can implement Parse JS SDK, my life changed again.
npm install parse
The App Id and Client ID, are protected now. I decided to give a try to NodeJS for this project. As a human being, I decided not to use a Node framework. So I ended up using this dependencies:
var url = require('url'); var http = require('http'); var fs = require('fs'); var replace = require("replace"); var Parse = require('parse').Parse;
I worked on a small framework after all. At the begging of the home page we find:
I specified the class name that Parse will search. So, I say %search:User% if I want to search for the users. A cool trick I implemented that was the URL search. If you go to a page with %search:Event% it will search all the events. You can specify to only search 1 event by the url page.com/event/ObjectId
To retrieve the data of an object, I tell to node where I want to display the info. %name% will show me the name of the object.
<div class="thumbnail"> <img src="%Event:banner:image%" /> <div class="caption"> <h1>%Event:name%</h1> <p>%Event:date:date%</p> <p class="descriptionText">%Event:description%</p> <ul>%Event:tags%</ul> <p><a href="event/%Event:id%" class="btn btn-primary" role="button">View</a> </div> </div>
In Candy Monster Game we have hungry monsters, we call them "Pateat". Pateats are very, very hungry and they want to eat you :). You have no weapons so you know that fighting a Pateat is not a good idea. So how can you escape? You will see on the some space candy flying over the universe, feeding the Pateat with it will make him not hungry. You must to be smart enough to make, the Pateat follow you and eat the candy that's on the path. Once the Pateat is not hungry you'll be able to advance.
To make a Pateat follow you we applied a chasing algorithm. When ever you are on the sight view field of the Pateat we will follow you. You can use the objects to hide from the Pateat.
We came out with a simple solution. Remember y = xm + b, the algebra formula that represent straight lines? We first create an offset vector, by subtracting the Pateat position from the player position. The offset vector has to be normalise, so that's our second step. This is saying how many units we are moving on x and y on each frame render. We multiple a speed constant to our normalised vector so it moves faster. This multiplication we be you moving velocity.
var offset : Vector2 = target.transform.position - transform.position ; var normalize : Vector2 = offset.normalized; var moveVelocity : Vector2 = normalize * speed; rigidbody2D.velocity = moveVelocity;
So if any obstacle are between the Pateat and you, the monster will follow. The previous code show how we move the monster toward the player's position.