Catch The Square

If you have completed an application and wish to share the complete source/project files with everyone then please post it in here. Source-code files only, no tutorials.
1 post Page 1 of 1
Contributors
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Catch The Square
mikethedj4
Weave: http://kodeweave.sourceforge.net/editor ... 9e581f2626

Here's a simple & basic game I made for my nephew.

Screenshot:
catch-the-square.png
The goal is simply just to catch the square. I did not incorporate a timer or anything like that. (We do that ourselves, makes it a little more fun)

I made this in just a few minutes last week and before I remove it completely I thought I'd release the source on here and see if any of you may want to mod it and use it for your own game.

Anyway here you go enjoy!

Requires JQuery and Normalize.

HTML:
Code: Select all
<div class="catch"></div>
CSS:
Code: Select all
body {
  background: #000e28;
  font: 600 23px courier;
  color: #bcffc1;
  padding: 0;
  margin: 0;
}

.catch {
  top: 0;
  left: 1px;
  padding: 1em;
}
JQuery:
Code: Select all
var count = 0;
$(".catch").html("");

(function makeDiv(){
  var divsize = ((Math.random()*100) + 50).toFixed();
  var color = '#'+ Math.round(0xffffff * Math.random()).toString(16);
  $newdiv = $('<div class="grab" />').css({
    'width':divsize+'px',
    'height':divsize+'px',
    'background-color': color
  });

  var posx = (Math.random() * ($(document).width() - divsize)).toFixed();
  var posy = (Math.random() * ($(document).height() - divsize)).toFixed();

  $newdiv.css({
    'position':'absolute',
    'left':posx+'px',
    'top':posy+'px',
    'display':'none'
  }).appendTo( 'body' ).fadeIn(100).delay(300).fadeOut(200, function(){
    $(this).remove();
    makeDiv(); 
    $('.grab').bind("click", function() { 
      count++;
      $('.catch').html(count);
    });
  }); 
})();
You do not have the required permissions to view the files attached to this post.
1 post Page 1 of 1
Return to “Source-Code”