`:+shdmNMMMMNmdhs+:` `/smMMNdyo+/::::/+oydNMMmy/` :yMMms/. +/ ./smMMy: +mMNs- +M. .oNMm+ :mMm/ mMh` /mMm/ `yMMo . NMMN- +NMy` `mMm- y+. sMMMN .mMm. `mMm` `yMMd+ `MMMM: : `dMm` yMN. .dMMo/MMMM/ hd` `NMh :MM+ o` :MMMMMMMM/ yMh /MM/ yMN Nd. /MMMMMMMMd/oMMN :d` NMh NMy oMMdyyMMMMMymMMMMMMN- `dMy yMM MMs sMMMMMMMMN`:NMMMMMs-+NMMs oMM NMy //` sMMMMMMMN. .NMMMMMMMMMy` yMM hMN `yMd+ `MMMMMMomm oMMMMMMMMo h+ mMd :MM+ sMMmsdMMMNM: sh. yMMMMMMMM.:dM/ /MM/ hMN. `NMMMMMM/yM: yMdMMmMMMMMMMN `NMd `mMd` yMMMMMm +MM- ://MN.MMMMMMM+ `dMm` .mMm. /MMMMMM+ :+` `/.:MMMMMMy .mMm. `yMN+ sMMMMdyo hMMMMMs +NMh` /mMm/ -hMMMm- `hMMMNy- /mMN/ +mMNo. `/shmms` .hNmho: .omMNo` /hMMms/` `:smMMh/ `/ymMMNhso+/::::/+oshNMMmy/` `:+yhmNMMMMMMNmhyo:`No code this time, sorry!
Saturday, October 25, 2014
MOLOTOV
My friend has no idea what this is. *sighs*
Tuesday, October 7, 2014
Wednesday, October 1, 2014
Javascript Random Text (i.e. ZALGONATION)
What this does
This is a little thing I invented whilst reading about the String.fromCodePoint and the respective identity getter. By generating a random number (thanks to Mozilla.org's developer wiki for the code of generating random integer) between the range of the normal text's points (30 - 126), and repeating that a random number of times.- window.setInterval(function(){
- title = document.getElementsByTagName("title")[0]
- title.innerHTML = ""
- var m = gI(2,20)
- for(i=0;i<m;i++){
- title.innerHTML += String.fromCodePoint(gI(32,126))
- }
- },20)
Final Notes
I'm on the Mozilla Developer wiki! Nothing big, duy, but I might be!Links
Thursday, August 21, 2014
Alphabet to numbers + CODE
Put this on your page to encode, scramble, and decode strings! It's amazing! :D
Usage
When using this, you must give credit, as this is under a Creative Commons License (see sidebar for more information)Notes
- Does not retain capitalization or punctuation
- Spaces are replaced with a '<space>' Sub-string after the initial encoding. You would have to replace this manually if you don't like it.
Try it out!
String:
Offset:
Offset:
Code
- /*
- ccccc ooooo dddd eeeee
- C O O D D E
- C O O D D Eee
- C O O D D E
- ccccc ooooo dddd eeeee
- Copyright 2014 Conor O'Brien under a Creative Commons Attribution 4.0 International License.
- */
- var alphabet = {
- lower: ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],
- upper: ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],
- number: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
- }
- String.prototype.encode = function(){
- var str = this.valueOf();
- var returnStr = [];
- var notAny = false;
- str = str.toLowerCase()
- str = str.split("")
- for(i = 0; i < str.length; i++){
- for(h = 0; h < alphabet.lower.length; h++){
- if(str[i]==alphabet.lower[h]){
- returnStr.push(h+1)
- } else {
- notAny = true;
- }
- }
- if(str[i]==" "){
- returnStr.push("<space>")
- } else if(!notAny){
- returnStr.push(str[i])
- }
- notAny = false;
- }
- returnStr = returnStr.toString();
- while (returnStr.search(",") !== -1){
- returnStr = returnStr.replace(","," ");
- }
- return returnStr;
- }
- String.prototype.scramble = function(number){
- var str = this.valueOf();
- var returnStr = [];
- var notAny = false;
- str = str.toLowerCase()
- str = str.split(" ")
- for(i = 0; i < str.length; i++){
- for(h = 0; h < alphabet.number.length; h++){
- if(str[i]==alphabet.number[h]){
- returnStr.push(alphabet.number[h] + number)
- }
- }
- }
- returnStr = returnStr.toString();
- while (returnStr.search(",") !== -1){
- returnStr = returnStr.replace(","," ");
- }
- return returnStr;
- }
- String.prototype.decode = function(){
- var str = this.valueOf();
- var returnStr = [];
- str = str.toLowerCase()
- str = str.split(" ")
- for(i = 0; i < str.length; i++){
- for(h = 0; h < alphabet.number.length; h++){
- if(str[i]==alphabet.number[h]){
- returnStr.push(alphabet.lower[h])
- }
- }
- if (str[i]=="<space>"){
- returnStr.push(" ");
- }
- }
- returnStr = returnStr.toString();
- while (returnStr.search(",") !== -1){
- returnStr = returnStr.replace(",","");
- }
- return returnStr;
- }
Tuesday, August 19, 2014
The year is 2048!
First things first! I am, yes, apart of the 2048 craze. It's just one of those games that make you want to punch the living everything out of it, yes?
After playing for WHO KNOWS HOW LONG, I decided to play around with the Javascript.
4 = 22
8 = 23
16 = 24
32 = 25
64 = 26
128 = 27
256 = 28
256 = 28
512 = 29
1024 = 210
2048 = 211
Under application.js, one finds (on line 3) the program making a GameManager (found under game_manager.js), which takes the parameters of a grid size (4), an InputManager (KeyboardInputManager), an Actuator (HTMLActuator), and a StorageManager (LocalStorageManager). A new one is presumably created with each iteration of the loop (as it's found under "window.requestAnimationFrame"), but you can create one by simply typing into the console/command line on your 2048 page a variable as found here.
Of course, you have to create a prototype function (or a function that is applied to a certain object, like 'String.prototype.search = function(...' would be 'String.search(...')
Before doing what's stated above, you must do what is stated below (that is, here.)
And enjoy!
Observations
One: This Is a JavaScript Job
Fiddling with the CSS, I made a 'Night' Theme (which I use, as it's preferable to the default). Anyone who has made a texture for 2048 would know that the JS 'pushes' (like you would do for an array item) a class to the tile upon it's creation. The CSS identifiers for this are:- .tile-<value>
- <value> is either 2, 4, 8, 16...1024, or 2048
- .tile
- Describes the animation of the tile.
Two: The JavaScript code is Complicated
With 10 JS Game-related files, one may be overwhelmed. There are 7 non-pollyfil files, which are listed below:- application.js
- game_manager.js
- grid.js
- html_actuator.js
- keyboard_input_manager.js
- local_storage.js
- tile.js
Three: All of the tiles are powers of two
..And, as a friend tells me, most are Mojang's Most Popular Game's resolution for Resource/Texture packs. 2 = 214 = 22
8 = 23
16 = 24
32 = 25
64 = 26
128 = 27
256 = 28
256 = 28
512 = 29
1024 = 210
2048 = 211
What this does
This is a code that will add a tile whose value can be anything, not limited to the powers of 2.Under application.js, one finds (on line 3) the program making a GameManager (found under game_manager.js), which takes the parameters of a grid size (4), an InputManager (KeyboardInputManager), an Actuator (HTMLActuator), and a StorageManager (LocalStorageManager). A new one is presumably created with each iteration of the loop (as it's found under "window.requestAnimationFrame"), but you can create one by simply typing into the console/command line on your 2048 page a variable as found here.
Of course, you have to create a prototype function (or a function that is applied to a certain object, like 'String.prototype.search = function(...' would be 'String.search(...')
Before doing what's stated above, you must do what is stated below (that is, here.)
And enjoy!
Codes
The Tile Manager Prototype
- GameManager.prototype.addTile = function (value) {
- if (this.grid.cellsAvailable()) {
- var tile = new Tile(this.grid.randomAvailableCell(), value);
- this.grid.insertTile(tile);
- }
- };
The New Game Manager
- var Gamer = new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
Syntax and Usage
All possible (legitimate) tiles.- Gamer.addTile(2);
- Gamer.addTile(4);
- Gamer.addTile(8);
- Gamer.addTile(16);
- Gamer.addTile(32);
- Gamer.addTile(64);
- Gamer.addTile(128);
- Gamer.addTile(256);
- Gamer.addTile(512);
- Gamer.addTile(1024);
- Gamer.addTile(2048);
A final note
This is not a developers tactic--it has many glitches, and is not guaranteed to be cross-browser. Glitches can also occur due to the separate Game Managers trying to manage the same game, and can result in two separate respective games going on at once. Use with caution, and, by using this, you accept the Terms and Conditions of Service listed below.Terms and Conditions of Service
Article I - Definitions
- The term 'Blog post' is defined herein as an article in which is written a paragraph or more.
- The term '2048 Game' or '2048 puzzle' or '2048' is defined herein as the original game hosted on the url "https://gabrielecirulli.github.io/2048/" (Link: here)
- The term 'Usage' is defined herein as taking the codes provided within this Blog Post and applying them to the 2048 game.
- The term 'Code' or 'Codes' refers to any of the Ordered List Item Groups (<ol>) that contain(s) a programming language (of which could be JavaScript, CSS, or HTML on this page).
- The term 'User' or 'The User' is defined as the person or persons using the Codes provided on this page.
Article II - Main Requirements
- Usage of the contents within the Blog Post can only be used for testing or for gratification of beating the game. You may not claim any results of using this code as anything besides that of which it is (which is the results of an edit of the JavaScripting). All screenshots of a game edited with the code provided in this blog post (or any alterations of said code) are strictly prohibited. The code can and will be taken down if multiple persons fail to comply to the Terms and Conditions of Service.
- These Terms of Service may and will be updated if necessary. Failure to comply with the alterations of the Terms of Service will be an infraction like any other. Ignorance of the Terms is the fault of the User
- All Content on the page is under a Creative Commons Attribution 4.0 international license.
Sunday, August 17, 2014
JavaScript Routines Part 2: Canvas (whole)
So what this is here is some things I've pieced together, including drawing prisms and cubes.
- var canvas;
- var ctx;
- window.onload = function(){
- canvas = document.getElementById("canvas")
- ctx = canvas.getContext('2d')
- }
- function Circle(ctx,x,y,r){
- // x = top corner X y = top corner Y
- // r = radius ctx = canvas context
- ctx.fillStyle = "#000000"
- ctx.beginPath();
- ctx.arc(x+r,y+r,r,0,Math.PI*2,true);
- ctx.stroke();
- }
- function rectRound(ctx,x,y,width,height,radius){
- ctx.beginPath();
- ctx.moveTo(x,y+radius);
- ctx.lineTo(x,y+height-radius);
- ctx.quadraticCurveTo(x,y+height,x+radius,y+height);
- ctx.lineTo(x+width-radius,y+height);
- ctx.quadraticCurveTo(x+width,y+height,x+width,y+height-radius);
- ctx.lineTo(x+width,y+radius);
- ctx.quadraticCurveTo(x+width,y,x+width-radius,y);
- ctx.lineTo(x+radius,y);
- ctx.quadraticCurveTo(x,y,x,y+radius);
- ctx.stroke();
- ctx.fill();
- }
- function prism(ctx,x,y,width,height,depth,lineWidth,fillStyle){
- // x = top corner X y = top corner Y
- // ctx = canvas context
- // example: prism(ctx,150,150,200,200,200,2,"rgba(22,0,22,.9)")
- depth /= 3;
- // COLORS
- ctx.strokeStyle = "rgba(0,0,0,0)";
- ctx.fillStyle = fillStyle;
- ctx.beginPath();
- ctx.moveTo(x,y);
- ctx.lineTo(x,y+width);
- ctx.lineTo(x+width,y+width);
- ctx.lineTo(x+width+depth,y+width-depth)
- ctx.lineTo(x+width+depth,y-depth)
- ctx.lineTo(x+depth,y-depth)
- ctx.fill();
- // LINES
- ctx.strokeStyle = "#000000"
- ctx.lineWidth = lineWidth;
- ctx.lineJoin = "miter";
- ctx.beginPath();
- ctx.moveTo(x,y);
- ctx.lineTo(x+width,y);
- ctx.lineTo(x+width,y+height);
- ctx.lineTo(x,y+height);
- ctx.lineTo(x,y);
- ctx.lineTo(x+width,y);
- // MOVING X AND Y DEFAULTLY
- x+=width;y+=height;
- ctx.moveTo(x,y);
- ctx.lineTo(x+depth,y-depth);
- ctx.lineTo(x+depth,y-height-depth);
- ctx.lineTo(x,y-height)
- ctx.moveTo(x+depth,y-height-depth);
- ctx.lineTo(x+depth-width,y-height-depth);
- ctx.lineTo(x-width,y-height);
- ctx.stroke();
- }
- function cube(ctx,x,y,width,lineWidth,fillStyle){
- // x = top corner X y = top corner Y
- // ctx = canvas context
- // example: cube(ctx,150,150,20,2,"rgba(44,22,44,1)")
- depth = width / 3;
- height = width;
- // COLORS
- ctx.strokeStyle = "rgba(0,0,0,0)";
- ctx.fillStyle = fillStyle;
- ctx.beginPath();
- ctx.moveTo(x,y);
- ctx.lineTo(x,y+width);
- ctx.lineTo(x+width,y+width);
- ctx.lineTo(x+width+depth,y+width-depth)
- ctx.lineTo(x+width+depth,y-depth)
- ctx.lineTo(x+depth,y-depth)
- ctx.fill();
- // LINES
- ctx.strokeStyle = "#000000"
- ctx.lineWidth = lineWidth;
- ctx.lineJoin = "miter";
- ctx.beginPath();
- ctx.moveTo(x,y);
- ctx.lineTo(x+width,y);
- ctx.lineTo(x+width,y+height);
- ctx.lineTo(x,y+height);
- ctx.lineTo(x,y);
- ctx.lineTo(x+width,y);
- // MOVING X AND Y DEFAULTLY
- x+=width;y+=height;
- ctx.moveTo(x,y);
- ctx.lineTo(x+depth,y-depth);
- ctx.lineTo(x+depth,y-height-depth);
- ctx.lineTo(x,y-height)
- ctx.moveTo(x+depth,y-height-depth);
- ctx.lineTo(x+depth-width,y-height-depth);
- ctx.lineTo(x-width,y-height);
- ctx.stroke();
- }
- function transPrism(ctx,x,y,width,height,depth,lineWidth,opacity,fillStyle){
- // x = top corner X y = top corner Y
- // ctx = canvas context
- // example: transPrism(ctx,150,150,200,200,200,2,.5)
- prism(ctx,x,y,width,height,depth,lineWidth,fillStyle);
- ctx.lineWidth = lineWidth;
- ctx.lineJoin = "miter";
- ctx.strokeStyle = "rgba(0,0,0," + opacity + ")"
- depth /= 3;
- ctx.moveTo(x+depth,y+height-depth);
- ctx.lineTo(x+depth,y-depth);
- ctx.moveTo(x+depth,y+height-depth);
- ctx.lineTo(x,y+height);
- ctx.moveTo(x+depth,y+height-depth);
- ctx.lineTo(x+width+depth,y+height-depth);
- ctx.stroke();
- }
Saturday, August 16, 2014
JavaScript Routines Part 1: CIRCLES!
- function Circle(ctx,x,y,r,fillStyle){
- // x = top corner X y = top corner Y
- // r = radius ctx = canvas context
- ctx.fillStyle = (typeof fillStyle === "undefined") ? "rgb(0,0,0)" : fillStyle;
- ctx.beginPath();
- ctx.arc(x+r,y+r,r,0,Math.PI*2,true);
- ctx.stroke();
- }
Subscribe to:
Posts (Atom)