Last Good Quote: Son's are the seasoning on our lives. - Someone on Facebook

Saturday, March 29

Interesting Javascript Libraries

Stumbling across some interesting stuff...

Heat Maps:
http://clicky.com/


Easy Installation of Auto Complete
http://www.brandspankingnew.net/specials/ajax_autosuggest/ajax_autosuggest_autocomplete.html

Gray Box/Light Box/In page popup
http://orangoo.com/labs/GreyBox/
http://www.lokeshdhakar.com/projects/lightbox2/

Auto Comment you JS code
http://smartcomments.github.io/

Megamenu - Drop Downs with options
http://www.javascriptkit.com/script/script2/jkmegamenu.shtml

Form Menu Hints
http://www.javascriptkit.com/script/script2/formfieldhints.shtml


Wednesday, March 26

Templates Links


Collections



Ones I like:




Css Buttons:

Saturday, March 22

JS Starfield

The following will create a flowing field of stars on a black background. Used the HTML5 Canvas element to create this effect:

<script>

var canvas = "";
var context = "";
var stars = new Array();



function loadStarfield()
{
canvas = document.getElementById("canvas_starfield");
context = canvas.getContext("2d");

addNewStars(100);

//stars[stars.length-1].starSize = 50;
//stars[stars.length-1].drawColor = "#333";
//stars[stars.length-1].position.x = -10;
//stars[stars.length-1].position.y = 150;
//stars[stars.length-1].velocity.x = 1;


starfieldLoop();

}


function starfieldLoop()
{
context.fillStyle = "black";
context.fillRect(0, 0, canvas.width, canvas.height);

for(var i=0;i<stars.length;i++)
{
drawStar(stars[i]);
stars[i].animate();
}

window.requestAnimationFrame(starfieldLoop);

}

function drawStar(star)
{
  var position = star.position;
  context.fillStyle = star.drawColor;
  context.beginPath();
  context.arc(position.x, position.y, star.starSize, 0, Math.PI * 2);
  context.closePath();
  context.fill();
}




function addNewStars(numStars)
{
for (var i = 0; i < numStars; i++)
{
stars.push(new Star());
}
}

function Star() {
  this.position = new Vector(randBetween(0,canvas.width),randBetween(0,canvas.height)); // Vector
  this.velocity = new Vector(randBetween(1,5),0);
  var c = randBetween(0,9);
  this.drawColor = "#FFF"; //"#" + c + "" + c + "" + c; // So we can tell them apart from Fields later
  this.starSize = randBetween(1,1);
}

Star.prototype.animate = function()
{
this.position.add(this.velocity);

if(this.position.x > canvas.width)
{
this.position.x = 0;
}
}



//////////////////////////////////////////////////////////////////////////////////////////////
//
// Utils
//
//////////////////////////////////////////////////////////////////////////////////////////////
function randBetween(min, max)
{
return Math.floor(Math.random()*(max-min+1)+min);
}

function Vector(x, y) {
  this.x = x || 0;
  this.y = y || 0;
}

// Add a vector to another
Vector.prototype.add = function(vector) {
  this.x += vector.x;
  this.y += vector.y;
}

// Gets the length of the vector
Vector.prototype.getMagnitude = function () {
  return Math.sqrt(this.x * this.x + this.y * this.y);
};

// Gets the angle accounting for the quadrant we're in
Vector.prototype.getAngle = function () {
  return Math.atan2(this.y,this.x);
};

// Allows us to get a new vector from angle and magnitude
Vector.fromAngle = function (angle, magnitude) {
  return new Vector(magnitude * Math.cos(angle), magnitude * Math.sin(angle));
};

</script>

<canvas id="canvas_starfield" width="600" height="300"
style="
border:5px solid black;">
</canvas>
<script>
loadStarfield();
</script>



Friday, March 21

Interesting Map Building Links


Ray Casting in 2D Top Down Tiles
http://www.codeproject.com/Articles/15604/Ray-casting-in-a-2D-tile-based-environment

Auto Tiling/Laying Tiles Programtically/Tile Laying algoithm
http://www.saltgames.com/2010/a-bitwise-method-for-applying-tilemaps/

Other Links
http://stackoverflow.com/questions/8901987/map-tiling-algorithm




Wednesday, March 19

Articles on World Building

World Building and World Auto Generation

Simple Rogue Like -
http://kuoi.org/~kamikaze/GameDesign/art07_rogue_dungeon.php

Random 2D Tile Map Generation
http://stackoverflow.com/questions/11968167/random-2d-tile-map-generating-algorithm?rq=1


Tuesday, March 11

To My Son and My Future Self


I love you son. I want to be your friend. I want to be your confidant. I want to be your rock in stormy times. But I am your father first and foremost. That means I must prepare you for the world as best as I can. That means I must ask you to do better than me. That means I must ask of you the hard things in life. I must force you to confront your issues head on, with your head up and your eyes open. I apologize if in your youth this strains are relationship. But it is how things must be. I am your father.


You brought home poor grades, extremely poor grades. At first I was angry at you. Very Angry. I dreamed of ways to punish you and make you FEEL the retribution. How I would make you quake with the fear of god himself. Make you feel as if the very wrath of the world was upon your head. It felt good to think these things. Yes, I knew the exact methods I would take to ensure you could not contemplate a failure like this again. I had it figured out...down to the last belt stroke.


But I gave myself time. Time to simmer down. Time to realize that my anger was driven by something else. (A lesson you would be wise to learn: Anger is never the REAL reason, it is an excuse to take action). I realized that I was ashamed, embarrassed that a son of my genes, a boy with the creativity, wit and intelligence equal to my own, could not do moderately well in school. I was embarrassed because this was a public reflection of my lack of mentorship to you.  My lack of showing you how to apply discipline and persistence. My lack of teaching you what was important and what was not. It was not you who had failed, but I who had failed you. My lack of showing you how take on a challenge and succeed. This failure was on both of us. This was humbling.

I now contemplate a gentler approach, but one that will test the limits of our relationship. I will teach you how to do this thing. I will teach you how to excel at the game of life. Oh, there will be punishment but it will be with measured and calculated to demonstrate to you that there are immediate consequences for poor decision makings. Especially when one can choose a better road. Rewards will come as well, but not given cause you are "due" them, but given because you earned them by taking the harder, longer, less traveled road.

I do wonder at what point it was that this failure on my part began. I love you. I spend time with you. I take you out. I take you to hang out. I find friends for you. I taught you how to talk, walk, read, ride a bike. Never let it be said that I did not care and spend time with my son.

But I was never hard on you. Never. And shame on me for it. I claimed I wanted you to have a “nice” childhood. Not realizing that in the “roughness” of a no, there is a challenge to the little mind. A challenge to the idea that not all things come by way of words, tears, smiles and hugs. But the idea that some things only come by the hard work of your own hands. In wanting you to have an easier time of childhood, an easier one than mine, I made you unable to handle struggle.

You're 14. Maybe you are too old, I hope not. But change is in the air. I know this will start a war between the two of us. I know at your current age you will not understand. I know we may no longer be friends....for a time. This makes me terribly sad. But I know this is my responsibility. I know this right. I know this is what I need to do .... for you.

We start on this journey tonight, March 10th of 2014. I hope I have the fortitude to stay with this. I do this for myself, I do this for you and I do this for the future generations. I love you son.

Your Father,
Markus Beamer

Why:
I write this in the heat of the moment. I write it cause I have to catch this anger and bottle it up and use it to fuel me to do the right thing. I write it so one day in the far future you will know I did these things for the right reason. However it works out.

I make this public because a public declaration of intention is the strongest way to re-enforce me taking personal actions.

I also know that I am not the only one struggling with this issue, it is driven from a true love for my children. Hopefully others can learn from my mistakes.

Saturday, March 1

Spawning Monsters

I've been thinking about monster spawning. For those that might now know, this means to place a new enemy creature on a map. A few thoughts I have.

As I develop the monster spawning will get progressively complex, so this is an iterative approach.

Variables:
MaxMonstersNearBy
Spawn Point - Coordinates of spawn point
Spawn Radius - As a player moves monsters will spawn within this area


  1. Check if there is more than MaxMonstersNearBy, if so exit. MaxMonstersNearBy will be set by the particular segment of the map the player is on.
  2. Check if there any players within viewing distance of the spawn point. If so exit. We don't want monsters to "pop" on the screen, players will wonder into them, or monsters will wonder into players
  3. Spawners will have a maximum number of monsters they can have spawned at any point in time.
  4. Check if there any spawn points outside of viewing distance but within SpawnRadius of the player. For each spawn point proceed.
    1. Choose a random leader, whose level is within 1 level of the player.
    2. Leaders have a number of followers that will spawn with them.
    3. Place the leader and the followers on an empty spot near the spawn point.

AI:
  1. Monsters will have one of the follow modes specified:
    1. Attack - Aggressively chase any player within x distance
    2. Guard - Stay still and attack only when attacked
    3. Wander - Moves randomly in a direction
    4. Follow - Follow a given unit, in the event that unit can not be found, start to wander.
  2. Leaders will set the mode of all followers
  3. Followers with no leader will go into wander mode.
Realistic Movement:
  1. Recall that AI processing (aiThinker) is only called once every few seconds.
  2. AI will choose 5 waypoints and move between those waypoints until the aiThinker is called again.
This is for my game Blades of War.



Followers