Sorasyn

Sorasyn

Joined
Sep 07, 2009
Interests
Programming, Building PCs, etc..

Activity Stream

Sorasyn created a Page  -  Jan 07, 2016

How long it's been since I've made a submission here. Just about two years, in fact.

Sorasyn   -  Dec 02, 2015

Hello, friends. Anyone still alive out there?

Sorasyn   -  Mar 30, 2015

For the past few months I've been oddly fascinated by the creativity and projects created using a simple Raspberry Pi board. So I decided to pick one up for myself, along with a few gadgets for my little Raspberry Pi 2, as a sort of "starter kit." Among those gadgets are a Bluetooth, and Wi-Fi USB dongle.

I was particularly fascinated by a fellow who had written a program to detect when certain registered Bluetooth devices came within range of the device. He had mounted his module in his house, clocking recognized devices as they came and went from the house as the day progressed. He then used this data, maintained a list of who was currently at home, and presented this data to the owner over the internet.

Aside from that, a cheap $35 quad-core home-based file server is never a bad thing.

Sorasyn   -  Dec 13, 2014

Alright, so I've been working on a Checkers game in my free time using HTML 5 and JS. While I've not made a lot of progress just yet, I have hit somewhat of a brick wall. I'm not all that proficient in JS just yet, but I've done a fair amount of research concerning it, to little avail.

My problem is I can create and load images just fine, but when it comes to drawing them properly onto the canvas is when I get problems. When using drawImage(...); calls outside a loop, they will draw correctly, and more importantly, at the correct coordinates. Conversely, if I were to place a drawImage(...); call inside a loop, the images will display correctly, but at the coordinates of the last image to be drawn.

document.addEventListener('DOMContentLoaded',onLoad,false)

/* Holds information about a game piece on the board */
function onLoad() {
    /* Grab the canvas element & context drawer */
    var canv = document.getElementById("board");
    var ctxt = canv.getContext("2d");

    /*Initialize Board & Game Values*/
    var rows      = 8;
    var cols      = 8;
    var evenTiles = "#CCC";
    var oddTiles  = "#444";
    var board     = [];
    var red       = new Image();
    red.src       = "Images/Red.png";
    var black     = new Image();
    black.src     = "Images/Black.png";

    /* Initialize the underlying array "pieces" to default values */
    for (a = 0; a < rows; a++) {
        row = [];
        for (b = 0; b < cols; b++) {
            if (a < 2) {
                if ((a % 2) == 0)
                    if ((b % 2) != 0)
                        row.push(new Piece(Piece.Color.RED, Piece.Status.NORMAL, b, a));
                    else
                        row.push(null);
                else
                    if ((b % 2) == 0)
                        row.push(new Piece(Piece.Color.RED, Piece.Status.NORMAL, b, a));
                    else
                        row.push(null);
            }
            else if (a > (rows - 3)) {
                if ((a % 2) == 0)
                    if ((b % 2) != 0)
                        row.push(new Piece(Piece.Color.BLACK, Piece.Status.NORMAL, b, a));
                    else
                        row.push(null);
                else
                    if ((b % 2) == 0)
                        row.push(new Piece(Piece.Color.BLACK, Piece.Status.NORMAL, b, a));
                    else
                        row.push(null);
            }
            else
                row.push(null);
        }
        board.push(row);
    }

    /* Draw the game board to the canvas */
    for (a = 0; a < rows; a++) {
        var row = (canv.height / rows) * a;
        for (b = 0; b < cols; b++) {
            var col = (canv.width / cols) * b;

            if ((a % 2) == 0)
                if ((b % 2) == 0)
                    ctxt.fillStyle = evenTiles;
                else
                    ctxt.fillStyle = oddTiles;
            else
                if ((b % 2) == 0)
                    ctxt.fillStyle = oddTiles;
                else
                    ctxt.fillStyle = evenTiles;

            ctxt.fillRect(row, col, (canv.height / rows), (canv.width / cols));

            //# PROBLEMATIC CODE #
            if (board[a][b] != null) {
                var piece = board[a][b];

                if (piece.Color == Piece.Color.RED)
                    red.addEventListener("load", function () { ctxt.drawImage(red, piece.X * 100, piece.Y * 100) }, false);
                else
                    black.addEventListener("load", function () { ctxt.drawImage(black, piece.X * 100, piece.Y * 100) }, false);
            }
            //# END PROBLEMATIC CODE #
        }
    }
}

The above code produces the following which draws all the pieces on top of one another at the last image's coordinates.

result

I'm thinking that the coordinates are changing, before the image is fully drawn, thus prompting the renderer to keep re-drawing it each time the variable changes. However, on the other hand, one would think that it has ample time to fully draw an image before it's called upon a second time.

Any suggestions?

Sorasyn   -  Dec 08, 2014

Something happened to my wonderful avatar picture. I'm now a blue circle with a white power button.

Sorasyn   -  Sep 17, 2014

@Hawkee You've got some rogue Navigation bar icons in the mobile layout on an iPhone 5S.

Sorasyn   -  Sep 06, 2014

Looks like the advertising bots are alive and well.

 Respond  
Sorasyn commented on a Page, [ComputerCraft] Turtle Wheat Farm  -  Apr 11, 2014

Very cool! I had a small something like this worked up on an old FTB world of mine, although it wasn't nearly as comprehensive. I'll have to give this a shot next time I get a chance.

 Respond  
Sorasyn   -  Apr 03, 2014

So I'm a bit of a newbie with Javascript, and have been doing a good amount of research on click events. Sadly I've yet to resolve my problem of not getting any click events to fire on my pages, not a single one. the JS doesn't even seem to be getting evaluated at any point.

Things I've tried:

  • Calling the click event on a CSS classed HTML element.
  • Calling a "live" function on a CSS classed element.

I just need to call a simple click event on one element identified by a css class type. Can anyone offer some suggestions?

Sorasyn   -  Mar 04, 2014

Can anyone suggest a good website to get some flat UI icons? Not looking for anything special, just simple one color icons.

Sorasyn commented on a Page, Cool Meter  -  Feb 17, 2014

That's quite the broken piece of code you've brought to us today. Did you not do any basic testing or debugging?

First off, you don't have any closing brackets for anything. That'll cause all sorts of problems.

Lastly, you have a random integer generator for numbers 1 through 20, but check through 25.

Sorasyn   -  Feb 12, 2014

Holy spam.

Sorasyn   -  Feb 11, 2014

Just got done re-wiring the desktop for the second time, and they still look somewhat astray. Knocked 5c off my processor temps, and dug up some strange problems booting into Windows though. Odd.

Sorasyn   -  Feb 09, 2014

For being a first time Ruby on Rails programmer; it's definitely not making the ever crucial good first impression. That's even after the hour long journey of installing it and RVM; hitting wall after wall. An absolutely super job they did building a UNIX installer. /Facepalm

Sorasyn   -  Jan 16, 2014

Yeesh, I need a program to backup my Minecraft worlds more often. This is the second time this week I've had to fix the world, or restore to a previous version. >.>

Sorasyn created a Page  -  Jan 13, 2014

Thought I'd throw a snippet in here for those Minecrafters who like to play, and/or are familiar, with ComputerCraft. This is not actually a Bukkit platform snippet, it's just a straight Lua script to be used in game.

Sorasyn   -  Jan 05, 2014

@Hawkee Update the website some?

Sorasyn   -  Jan 01, 2014

Been pretty quiet around here for awhile. Anybody still alive out there?

Sorasyn commented on a Page, Java Hangman Game!  -  Dec 21, 2013

The UI design looks good for not implementing any sort of static placement code, or structured design classes. UI design is probably the number one thing I absolutely hate about Java. You either have to use some shoddy design class (GridBag, and such), or painstakingly place each component statically in the code. For the most part.

Nice little game.

 Respond  
Sorasyn created a Page  -  Dec 07, 2013
3,824 

As the title states, this is just a small class I've written to represent a Matrix object as seen every so often in various disciplines of mathematics. Matrices are, in programming terms, basically a two dimensional array of integers that can represent anything from trigonometric angles, and vectors; to any number of notable applications including tracking network paths, and applying cryptography calculations,..

  1 Thread   PHP  
Sorasyn   -  Nov 21, 2013

@Hawkee Is there some reason the search strips special characters before executing? I tried searching "C++ Tokenizer" and it only brought up results for "C Tokenizer," which were predominately out of date, and surprisingly irrelevant, mIRC snippets...

Sorasyn   -  Nov 19, 2013

For one of Google's creations, they sure are pretty reluctant at finding useful resources for a rusty Java programmer unfamiliar with the android 4.3 framework.

Sorasyn   -  Nov 12, 2013

@Hawkee The snippets page in mobile becomes a little jumbled on bigger descriptions pushing text onto other descriptions and other things of the like. On mobile that is.

Just a suggestion but it'd be nice to be able to search snippets by category like we're able to in scripts.

Sorasyn commented on a Page, Cryptoquip Generator [0.64 KB]  -  Nov 01, 2013
else continue

Is redundant since it's called at the end of an infinite loop.

By the way, care to add some description as to what the snippet actually does? As much as I can discern from the source it looks to obfuscate characters in some manner.

Sorasyn commented on a Page, Binary Calculator - Sockets  -  Oct 31, 2013

Would be magnitudes more efficient if you took the time to calculate it locally instead of reaching out to a website to do it. Not to mention doing it locally would require about 50% less code. Doing it this way does not guarantee longevity. In a few months or whenever they decide to update the website, it'll have to be redone to function properly again.

Sorasyn   -  Oct 16, 2013

@Hawkee I've noticed on a user's page, when they've not submitted any projects or any of the like, the page pulls up empty. The "filter" navigation bar has most notably gone missing.

Sorasyn   -  Oct 14, 2013

Haven't really contributed much here as of late. Perhaps I'll work up a frequency analysis project in C#, sometime over the weekend, and demonstrate it's various uses in XOR encryption breaking, and plagiarized text detection.

 Respond  
Sorasyn commented on a Page, C# code to download webpage  -  Oct 11, 2013

Wouldn't it be best to throw an NullReferenceException or an ArgumentNullException instead of an ApplicationException with the only helpful data being a website URL?

 throw new ArgumentNullException("Command line arguments expected, but not found."); 
Sorasyn   -  Sep 27, 2013

My last submitted work here finally breached the 1k mark. Woo.

@Hawkee : On an unrelated note, are we able to delete our own projects yet? I'd like to "clean" my profile if you will.. I sometimes cringe looking at my past projects.

Sorasyn commented on a Page, Quakenet Command script with Dialogs (2)  -  Sep 27, 2013

If it's seldom different than the last version then why would you even bother resubmitting it as another "snippet?" Why not just update the previous version?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.