1. NTFS Corrupted, Free Recovery Software?

    Date: 06/21/07 (Computer Geeks)    Keywords: software, html

    Hey everyone,

    Here's what happened. I was getting ready to make an image of my (XP Pro) workstation with Novell's Zenworks 7 in order to re-partition my hard drive so I can install and play with Vista in a dual-boot environment, without actually having to count on vista as my main OS.

    I have two 80gb SATA drives (not running RAID, IDE Emulation) in my workstation, I Copied all my personal information to the second hard drive, then pushed an image of the workstation up to the network (no need to sysprep if it's coming back down on the same workstation), re-partitioned my main drive into two 40gb partitions, and pulled the image back down on one of them.

    The workstation booted up just peachy with XP booting just fine and all my programs in tact, however, the second drive that I had moved all the information to was no longer available. In the disk manager it said the data was 'unallocated' so I made it active (without formatting it) and it is being recognized as a raw partition right now, but keeps asking me to format it when ever I try to access it.

    Now here's the question: did some googling and found this http://www.safe-install.com/programs/undelete-ntfs-partition-data.html which after running, will detect the files on the drive, HOWEVER, it is a trial version and I cannot actually restore the files without buying the software. Does anyone know of any Freeware that will allow me to restore NTFS files from a corrupted drive?

    Source: http://community.livejournal.com/computergeeks/1082394.html

  2. HTML newsletter problem

    Date: 06/26/07 (WebDesign)    Keywords: html

    This is driving me nuts, and I hope someone can help me. I've designed an HTML email newsletter. It's not overly image-laden, and all the images are optimized GIFs hosted on a server and called by URL. I didn't get fancy with formatting - just used a background color in one of the td's, and some color and font stuff to differentiate between two levels of headlines.

    The problem is, it's still 159K when it hits the inbox. I've streamlined as much as I know how. Now, here's the really weird part. There's a newsletter I subscribe to that has a fairly similar design, but with a ton of images... and it regularly hits only about 40K in my inbox. So, as a test, I copied the source code from the latest edition of that newsletter, put it into a file on my computer, and sent the newsletter to myself. It showed up at 679K!

    So apparently, there's some kind of compression happening somewhere when they send it out (or else Outlook Express is fattening when used as the sender).

    What the heck am I missing here?

    Source: http://community.livejournal.com/webdesign/1271005.html

  3. HTML newsletter problem

    Date: 06/26/07 (Computer Geeks)    Keywords: html, web, google

    This is driving me nuts, and I hope someone can help me. I've designed an HTML email newsletter. It's not overly image-laden, and all the images are optimized GIFs stored on a server and called by URL. I didn't get fancy with formatting - just used a background color in one of the td's, and some color and font stuff to differentiate between two levels of headlines.

    The problem is, it's still 159K when it hits the inbox, and I can't understand why it's so large. I've streamlined as much as I know how. Now, here's the really weird part, I think. There's a newsletter I subscribe to that has a fairly similar design, but with a ton of images... and it regularly hits only about 40K in my inbox. So, as a test, I copied the source code from the latest edition of that newsletter, put it into a file on my computer, and sent the newsletter to myself. It showed up at 679K!

    So apparently, there's some kind of compression happening somewhere when they send it out (or else Outlook Express is fattening when used as the sender).

    What the heck am I missing here?

    ETA: I have done exhaustive Google searches trying to find the answer to this question and have pored over every email newsletter design site I can find. All my efforts have come to naught.

    X-posted to '[info]'webdesign

    Source: http://community.livejournal.com/computergeeks/1084363.html

  4. 8600GT somewhat underwhelms, 8500GT not worth bothering

    Date: 06/27/07 (Computer Geeks)    Keywords: html

    3DMark06 8500GT and 8600GT scores
    http://nvnews.net/reviews/inno3d_8600gt_8500gt/page_2.shtml

    My Radeon X1900GT score (non-overclocked, everything stock. 4816 3D Marks, if the link doesn't work)
    http://service.futuremark.com/compare?3dm06=2315942

    When I saw it, I was surprised. Considering how high 8800 cards scores, the 8600GT scores are pretty horrid. It'd have to overclock to beat out my X1900GT. This is not to mention that my CPU was running slower than the test rig on the review site (2.66GHz versus 3GHz overclock on theirs)

    Man. It's like an 8600GT would be a downgrade for me.

    Even for the 8600GTS, it looks like I might be able to live without it too since the difference isn't quantum leap:
    http://www.nvnews.net/reviews/msi_geforce_nx8600gts/index.shtml

    This leaves the 8800GTS, which costs a whole lot more.

    Things just don't look heart-attack exciting from where I am right now.

    I won't even talk about the 8500GT.

    Source: http://community.livejournal.com/computergeeks/1084890.html

  5. IE7 freezing when QuickTabs feature enabled.

    Date: 06/27/07 (Web Development)    Keywords: css, html, xml, java, web

    I have a big web application, written in JS,CSS,XML/XSLT.
    Output size of HTML is 1.5Mb, ~700Kb javascript code, ~400Kb CSS code.

    When user open new tab (or use Quick-Tab feat.) IE try to generate thumbnail for this page. But page is so big, so IE freeze for 5-15 minutes. It's awfully. Solution of this problem is hiding all content (style.display = 'none' on general wrapper div.), this code was wrote in onblur event of the body element.

    Sometimes this solution works, sometimes not.

    Actually, the question:
    How I can catch tab-changing event? (seems to be eq. with body onblur).

    Thanks for advice.
    Best regards, Gleb M. Borisov.

    Update: Problem partially solved with code below:

    
    

    Source: http://community.livejournal.com/webdev/418200.html

  6. RSS?

    Date: 06/28/07 (WebDesign)    Keywords: html, web

    First of all, I just want to say... hi, and I love you guys. I always come to this community to ask (often dumb) questions about HTML or web design and 99/100 times get the answer I need. I've never really said how much I appreciate everyone in this community and am so glad it exists!! So thanks!!

    That said, here goes another (possibly dumb) question...
    I have a blog at Blogger.com. I would like the most recent 2 or 3 headlines and maybe a snippet of the latest blog post to appear on the home page of a separate website I own. Is there a simple way of getting this to happen?

    (As a note, I really don't care if the blog content is on Blogger.com or any other blog site, or even if I just type it into a txt doc... and I also don't care how many headlines show up or how much of the blog post is on the home page... so basically, I just want automatically updated blog content on my site that is integrated into the design of the home page.)

    Anyone done this before? Does FeedBurner.com help people do this sort of thing?

    Thanks!

    Source: http://community.livejournal.com/webdesign/1272479.html

  7. Overlapping text in Firefox 2.0.x

    Date: 07/01/07 (Computer Geeks)    Keywords: html, web

    Recently I have notices a rather annoying "feature" of Firefox 2. When going to certain websites the text that is around a link or title is overlapping and rendered quite unreadable. For example, when I go to Wikipedia normally I see this but when I log into my profile, which is using the "Nostalgia" skin, I see this. If memory serves me, I remember something similar to this happening in the earlier versions of Firefox that I had used (ver 1.0.x), but that was a problem with tables if I remember right, not with links/titles. I have found some information about this here, which appears to be similar, but that problem appears to be with displaying things in tables. This does not happen when I log into IE7. This only happens on certain pages, which taking the Wikipedia example, makes me think it is with some sort of html coding (though I'm not sure as to what plus if it is improper coding, Wikipedia seems to be a rather popular page to have bad coding). If anyone has any suggestions/fixes, I'll be happy to hear it. I almost forgot as well, some pages have text that you can't display because it is off the end of the page. Even making the screen bigger of maximizing doesn't help.

    Oh yes, i'm running Firefox 2.0.4 now, which I just upgraded from 2.0.2. After the upgrade it did the same thing. I also tried turning off the "linkification" plug-in, and turning off Greasemonkey. Neither worked.

    P.S. This problem also crops up when I view a preview of this entry.

    Source: http://community.livejournal.com/computergeeks/1085488.html

  8. iPhone Hack: Make Your Website Readable on iPhone & Blackberry

    Date: 07/02/07 (Java Web)    Keywords: rss, html, web

    Here is a simple one line change which will make your webpages viewable well on iPhone and Blackberry. Add the following to your HTML HEAD section: Apple is using the following on their RSS reader website: The other parameters you can experiment with: initial-scale (first loaded scale), user-scalable (boolean), minimum-scale (default 0.25), maximum-scale (default 1.6). There is [...]

    Source: http://blog.taragana.com/index.php/archive/iphone-hack-make-your-website-readable-on-iphone-blackberry/

  9. css popups

    Date: 07/02/07 (WebDesign)    Keywords: css, html, java

    i was wondering if there was a pure css way to make an image popup. i've seen a few on cssplay.co.uk and dynamicdrive.com but i want something that will pop up over the rest of the site with the ability to put html underneath it if i want to (captions with links maybe). i was wondering if anybody here knew of anything that i didn't. i'm currently using javascript to achieve the results i want and i'm not happy with how it has been working. the page is http://1919hemphill.org/calendar.html if you want to know what i'm talking about.

    thanks a lot in advance!

    Source: http://community.livejournal.com/webdesign/1276339.html

  10. PHP Market share anyone know?

    Date: 07/04/07 (PHP Community)    Keywords: php, programming, html, web

    Does anyone know a web site that shows the market share of php versus the other main web languages? The only one i could find is one based on book sales:(


    http://radar.oreilly.com/archives/2006/08/programming_language_trends_1.html

    Source: http://community.livejournal.com/php/574702.html

  11. Ajax

    Date: 07/06/07 (WebDesign)    Keywords: php, html, xml, database, java, microsoft

    I'm trying to teach myself how to use Ajax with PHP. It's been years since I've used JavaScript for anything so I'm beyond rusty.

    I've been using the Apress Beginning Ajax with PHP book and I've been learning quite a bit, but I haven't found a single code sample from that book that actually worked the way it was written.

    So, I come to you with my situation: Right now, I have one field in a form. There will eventually be more, but I'd like to see if I can get just a single field to work for me before I start jumping ahead. Anyway: 1 field on a form, and one submit button. In theory, when I click on the submit button, I'd like the value to be input into the database.

    I have bigger ideas for what I want to do with this project, but for now, just a little success with the database updating would be nice.

    Note: The code is based off of a contacts form I found on the internet. I figured for learning purposes, it would be a good way to start, that way, once I figure out the trick to making ajax do what I want in this instance, I can write my own.


    
    
      
        AJAX Recipe Form
        
        
        
      
      
        

    AJAX Recipe Form






    FYI: This'll be cross posted a bit.

    Source: http://community.livejournal.com/webdesign/1278123.html

  12. How To Draw Pretty Girls With HTML Table

    Date: 07/06/07 (Java Web)    Keywords: css, html, java

    If you thought HTML tables were passe, think again. Show me how you can draw the same picture using only CSS; I will then use it on my blog I think HTML tables are as useful as ever in representing tabular / spreadsheet type data. While recent Javascript libraries like YUI and Ext uses [...]

    Source: http://blog.taragana.com/index.php/archive/how-to-draw-pretty-girls-with-html-table/

  13. Trouble

    Date: 07/08/07 (PHP Community)    Keywords: php, mysql, html, database, sql

    I'm sorry to disturb, I'm new in php and I have a trouble with this code:

     

    It has to extract a row from a mysql database and make a html select of the value id_persona displaying also the value of the other fields (Nome, Cognome, Organizzazione) but it don't works properly. Choices on select are displayed like in the attached photo instead with the correct data .

    Source: http://community.livejournal.com/php/575883.html

  14. XML DOM vs. HTML DOM - Spare me XSLT

    Date: 07/09/07 (Javascript Community)    Keywords: browser, html, xml

    I have a deceptively simple problem.

    Using an XMLHTTPRequest object, I pull data off the server and grab it in the form of an XML Document object. As it happens, this data is actually well-formed XHTML. After I do some processing on this XML Document, I merely want to insert it into an output DIV tag.

    My initial instinct was to be as simple as possible: divTag.appendChild(xmlDoc);

    You might have already guessed- that doesn't work. Or, more accurately, it does work, exactly as it should. The code above appends the XML document object as XML data to the DIV. Which means the XHTML tags contained in the XML document are not interpreted by the browser.

    So, for illustration, I have an XML document like this:

    • Some data
    • Some more data


    I'd like to insert that XML data into a DIV, and have the browser recognize it as XHTML, and render it accordingly. It needs to be cross-platform. I'm not above turning it into a string and doing an innerHTML, but I'd really like to avoid that too.

    And while I'm poking with XML questions- I also need a cross-browser way of pulling an XML Document into a String- like the IE xmlDoc.xml property. I can't seem to find any property that makes Mozilla behave properly.

    Source: http://community.livejournal.com/javascript/135669.html

  15. Loading ASPX without a browser

    Date: 07/10/07 (Asp Dot Net)    Keywords: browser, html, asp, web

    Ok, this is going to sound really weird, and it's kind of hard to explain, but is there a way to take an ASPX file, and load its contents, allowing you to use code behind, without a browser?

    Basically here is what I need to do:

    I have an AJAX enabled web page, and I need to be able to use a lot of the AJAX enabled controls like the CollapsiblePanelExtender. The thing is, speed of loading the page is paramount, and even though the final data isn't that much, the business code to massage the data is huge and actually time consuming. What I need to be able to do, is on a daily basis, have a service that generates the page, and then stores the page, with the massaged data, to the DB. Then what happens is when the "page" itself is called by a user, it goes to the DB and gets my "aspx" code, and sends that down. It can't be generated HTML. Not going to get in to "why" here.

    Basically the "aspx" page would have asp controls on it like labels, but the text itself is already saved, and there is no need for code behind to generate the data.

    It's kind of like a template in that I'd have an ASPX page that is my "template" The service would then load the page as if it was in a browser, and it would go through and set the "Text" values on the Labels, text boxes, etc. etc. based on the data from the DB, but then instead of saving the generated HTML, it would just modify the ASPX itself, and I could then save that ASPX code to the DB.

    Currently what I do is create an ASPX page, and then rename it to a text file. The labels don't have any IDs or anything, and then I just go through and replace everything as text.

    I know there has to be a better way to do this. Any ideas?

    Source: http://community.livejournal.com/aspdotnet/90433.html

  16. PHP/MySQL UTF-8 SNAFU

    Date: 07/10/07 (Web Development)    Keywords: php, mysql, browser, html, database, sql

    Ok, so I have a fully UTF-8 MySQL database with a fully UTF-8 table. I have a php page which has "" at the top of the html section and "mysql_set_charset("utf8");" after my connection (it's php 2.2.3, so that's more or less the same as "mysql_query("SET NAMES 'utf8'");).  I have all my php.ini mbstring stuff configured for utf-8:

    mbstring.language = Neutral
    mbstring.internal_encoding = UTF-8
    mbstring.http_input = auto
    mbstring.encoding_translation = On
    mbstring.detect_order = auto

    and for what it's worth, echo mb_internal_encoding(); reports "UTF-8".

    when I run a query that pulls out (in this case, Japanese, but say any) UTF8 data, it displays properly in MySQL Query Browser.  With php in the above context however, it does not.  Instead, it prints a ? corresponding to each character.  When I use mb_detect_encoding(); on each such string, it tells me they are encoded as ASCII.  The nearest I can tell is that somewhere between using mysql_query() and mysql_fetch_row(), things got messed up.  Is this a bug?  Is there something I'm missing?  Any clues? Help!

    Source: http://community.livejournal.com/webdev/420578.html

  17. Toolbar buttons

    Date: 07/11/07 (Opera Browser)    Keywords: html

    These are nice:
    http://operawatch.com/news/2007/07/tip-open-pages-in-firefox-and-internet-explorer-directly-from-opera.html

    I can't find how to set up buttons like that. Is there some documentation I've missed?
    Here's some stuff on how to do buttons: http://people.opera.com/rijk/opera/dndbuttons.html

    Source: http://community.livejournal.com/opera_browser/66252.html

  18. web design trade?

    Date: 07/11/07 (WebDesign)    Keywords: html, web

    Hello all. :)

    I am just putting this out there.

    I have no web design skills. Well, maybe basic html. I'd love to do a trade with someone though who is a designer. I could offer photography and custom cyanotypes in return for website construction. I'm looking for a site that will be used for my import business. So sales, travel blog.

    Some of my images can be found at:

    http://latentimages.deviantart.com/

    If anyone is interested just drop me a note on my journal.

    Thanks. :)

    Source: http://community.livejournal.com/webdesign/1280633.html

  19. Hi, I need a bit of CSS help.

    Date: 07/11/07 (WebDesign)    Keywords: browser, css, html, web

    EDIT: Okay, I'm slowly making headway, I forgot about floats and clears and all that fun stuff, and I managed to get the layout to work the way I want in IE7, but of course, as these things happen, the codes aren't working in Firefox. These two anamolies are what are happening in that browser:
    1) When I make the entry div id float left, the background inherent in the pagebody div id that contains the entries and the sidebar disappears.
    2) The background from pagebody won't repeat as the sidebar increases in size. The background WILL repeat, however, if the entries increase in size. I don't understand why it will for one and not the other when both are contained within the same tags.

    It also seems that while the sidebar will now align vertically with the entries in IE7 it won't on Firefox.

    Any help appreciated, the files to take a gander at are:
    http://nolifeproductions.com/html/leaf/index.txt
    http://nolifeproductions.com/html/leaf/leaf.css

    (Also I realize the bugs more than likely come from the IE side of things, but IE is what I'm used to working in and generally I don't have such aggravating problems between browsers so I'm at a pretty good loss.)


    -----------------------------------------------------------------------------------------------
    Allrighty, so I'm making a journal layout, conceivably I want it to look like this:
    http://nolifeproductions.com/html/leaf/
    And it (seems) to be working fine as it is, but I was just wondering a couple of things about CSS. Everything in that layout essentially is positioned relatively, so it can float and recenter itself depending on a person's browser size. However, in that particular version of the layout the sidebar is positioned absolutely else it would look like this:
    http://nolifeproductions.com/html/leaf/index2.html
    The sidebar is shoved under the entries, which makes logical sense because it's floating relative to the position of the entry tags, however is there a way to have the sidebar remain relative in its position but have it look like it does in the version it's absolutely positioned?

    And finally, one more question, concerning the version with the sidebar positioned absolutely, if the sidebar is longer than the entries, the background pattern I have repeating in the pagebody tag won't extend along with the sidebar, even though I have the sidebar contained within the pagebody. IE it looks like this. I assume it's because of the absolute position, but again I was wondering if there was a way to fix it that I'm just not figuring out.

    I am trying to keep the CSS as simple as possible because I was making layouts with the common user in mind so they can easily implement it instead of having 20 pages of confusing codes, so if there are solutions to these problems that are simple I'd be very excited to use them. I wouldn't be surprised if the solutions are so simple I merely looked them over, which is so often the case, amirite.

    Thanks for any help.
    Oh and to make your life easier:
    Here's the CSS for the position:absolute sidebar layout
    and here's the CSS for the position:relative sidebar layout
    It's a bit messy, I haven't streamlined it yet, sorry.

    (Also, let me apologize if my "lingo" isn't the "official jive" of the webdeveloper world, and I hope that I'm making some sense. If you need me to clarify just ask.)

    Source: http://community.livejournal.com/webdesign/1280341.html

  20. JavaScript Pong

    Date: 07/13/07 (Javascript Community)    Keywords: programming, browser, html, asp, java, web, seo

    I wrote a JavaScript/XHTML based Pong game- mostly a proof of concept. I'm going to use this as the base of a browser-based Mario Brothers clone (not SUPER Mario- I'm not going to make this damn thing scroll if I can help it). That's a long-run project though. For now, I've got some basic plumbing done. It's got some bugs, etc- but I figured that since I had a (mostly) working library, I'd post my work so far, and share out the code.

    Take the game for a spin, and grab the code.

    Masturbatory Pong - My Design


    The design of my XHTML/JavaScript game can be broken down into several areas. What we'll do is examine each area in turn, discuss some of the whys-and-wherefores, and get a feel for how you can recycle that code later.

    General Design Goals


    The biggest design goal was reusability. To make reusable and flexible code, the biggest rule is weak-coupling. Nothing should have any dependencies on anything else. To meet that goal, I aggresively applied OOP principles and Aspect Oriented Programming. Some of this breaks down on the game itself, simply because that section contained application specific code, and I didn't care that much at that point. It's still weakly coupled, but not cleanly written.

    Program Components

    Core


    The DOM has all sorts of annoyances- mostly created by browser incompatabilities. Every developer, in every language, starts to develop a library of utility functions that they use again and again. In my case, the utility/library functions are contained in a file entitled DOMhelp.js.

    Originally, this file came from a book on JavaScript(Beginning JavaScript for Practical Web Development, Including AJAX). My incarnation bears little resemblence, save for event-management. It provided good utilities for handling events in a browser-independent fashion.

    The DOMhelp file contains a DOMhelp object literal. This is where the DOM event management code goes, as well as my custom functions. The important ones, for this application, are the "getControlLocation" and "translateClientToElementCoords". These are used to translate coordinates from the page area on screen to the element that will contain the game.

    Also in that file is the EventSource aspect. These sorts of functions are my approach to AOP in JavaScript. It takes a class as its parameter and appends a bunch of functions to that class prototype- in this case, it appends functions for managing and firing events. At some point, for performance, I may modify this to have the event-firing event code run in a seperate thread. As it is, it works fine so long as there aren't many listeners. It's a pretty standard implementation.

    This is my growing library of supporting code that I use in nearly every application.

    Animator


    The animator components are split across three major files, each specific to one function. The animator API is built around Sprites that can do their own frame management and collision detection, etc. Everything else is built to support those functions.

    Sprite.js

    The Sprite - General

    This was my starting point for designing this library. The Sprite class should do as little as possible- it should focus on rendering and providing the graphical aspects of the application. Any other functionality it requires should be appended via Aspects.

    The constructor requires a great deal of information, and all the parameters are documented. The only one that's really critical is windowFrameId- this tells the Sprite where to render its details.

    The Sprite - Frames

    For visual behaviors, the Sprite class tracks frames- each frame is stored in memory as an IMG element (for pre-loading). The Sprite tracks the frames in a set of arrays- each array represents a "frame-set"- a group of related frames that should display in a sequence. If you think of Super Mario, one series of frames plays when he walks left or right, jumps, or shoots a fireball, etc. It's all one Sprite, but different animations play based on the current application state.

    Frame-sets are defined when frames are added- the "addFrame" method takes a frame-set as a parameter. If the parameter isn't set, the Sprite puts frames into the default frame-set. In the case of the MPong application, we only use one frame-set for every Sprite. It would, however, be trivial to add more frames and frame sets to make a more graphically exciting game. I will probably updated it with better graphics and add logic to the collision detection system to switch between frame-sets to provide visual feedback.

    The Sprite gets quite interesting in the rendering process. Before we can really look at the rendering process, it's important to discuss the three aspects also defined in this file and their role in the process.
    The Sprite - Aspects

    The core Sprite code assumes that the Sprite has a location, a size, etc. but isn't responsible for maintaining those values. These values are appended to the Sprite class via Aspects. The Changeable aspect is the base here- it adds a boolean to track if the Sprite is "dirty"- only render dirty Sprites (for performance). A sprite HasLocation, HasSize- these are the keys for rendering. These allow us to track the position and size of a Sprite- which can then be rendered using floating DIV elements.

    It is worth noting the CollisionDetection Aspect, even though it has nothing to do with rendering. Based on the size and position of a Sprite, it has a collection of methods to check for collisions. Right now, it only supports rectangle-boundary collisions, but this could be easily expanded- without altering the Sprite class. This flexibility is why I chose to use Aspects.
    The Sprite - Rendering

    The "render" method is the entry point for the rendering process. It only does something if the Sprite has been marked as "dirty" (changed==true). If you glance through the code, you'll notice that changing frame-sets, advancing between frames, changing positions or sizes will all dirty a Sprite.

    Sprite rendering actually focuses on the "getContainer" method- this one is responsible for the real work of interacting with the DOM. This is the lowest-level method in the Sprite. It operates as a Factory Method wrapping a Singleton design pattern. It only creates the "container" once- a DIV element appended to the "windowFrameId" element. The "renderFrame" method is strongly-coupled to the structure of this DIV and its children, but that's trivial- the "getContainer" method just needs to always ensure that the first child of the container is the IMG responsible for displaying the current frame.

    Caveat: This does not set a z-order on the element. This is probably something that should be added (especially because z-order used in conjunction with a scaling logic could create "3D" UIs).

    Once we've got the container, "render" calls out to its Aspects to handle the job of positioning and sizing the DIV- again, we want the Sprite to be responsible for looks and looks alone. We'll rely on appended Aspects for the positioning/sizing logic. Once that's done, "renderFrame" is invoked- it simply updates the SRC of the IMG holding the frame. I'm fairly certain this is more effecient than modifying the DOM tree, but I haven't benchmarked it out.

    motion.js

    Movement - General

    I've said this a lot, but one more time- the Sprite should only be responsible for rendering itself. All other logic should reside elsewhere. For logic that the Sprite directly depends on- like size and position- it does reside in the class via Aspects. Movement is a complex area, and it should be even more weakly coupled to the Sprite.

    For this reason, I used a Provider model. The general formula is that a Provider tracks a list of sprites. It contains some algorithm for repositioning those sprites. The skeleton of this code is implemented in the GenericMotionProvider- "move" being the main method for the algorithm. What is important to note is that the GMP does not contain any logic for actually moving. It invokes an abstract method, "provideMotion". This should be implemented in child classes.

    There are two child classes in the API at this time- certainly something I intend to expand. One is a LinearScrollMotionProvider, responsible for any straight-line one-direction motion. The other is a MouseMotionProvider, which allows mouse-following motion. This last would be trivial to modify into a drag-motion provider.

    The biggest disadvantage to the design as it stands now is that the timer-driven providers (LSMP) have to be registered with a Clock, but event-driven providers (MMP) don't. This means that the client-code has to know which is which- I should probably modify this so that timer-driven providers take a clock in their constructor and register themselves, and not have the client code responsible. Fortunately, there's nothing explicitly wrong with registering the MMP with the Clock- it would just cause one more positioning cycle than is required. With something like the MMP, which is tracking a large number of events, one more cycle probably won't hurt performance much.
    Motion - LinearScrollMotionProvider

    The LSMP focuses on three major numbers- vert, horiz and increment. Wrap explains what to do when you reach the boundaries of the cavas area- if wrap is true, wrap around to the other side. Otherwise, stop.

    Vert, horiz and increment all work together to represent a motion vector. The math is simplified, but that's the essential purpose. Vert represents the extent of the of the vector in the vertical axis, horiz in the horizontal. Increment is the "scaling factor" on the vector. This does have one disadvantage- changing the vert or horiz values can change the speed. In MPong, that's fine- actually desired. It may be wiser, however, to implement a general-case version that uses vert/horiz as a ratio and increment controls the speed directly.

    Another flaw in LSMP is that it always calls setPosition, and hence always marks the Sprite as dirty. Again, in MPong, this isn't an issue- the ball always moves, so is always dirty and must be rerendered. In other applications, this could have a significant negative performance impact.
    Motion - MouseMotionProvider

    The MMP also tracks a vert/horiz parameter- these are multipliers to control the rate of motion versus the mouse. In most applications, these should be either zero or one- in MPong, the vert component is always 0, horiz is always 1. Other values can be used- for example, setting horiz to 2 means that for each pixel the mouse moves, the sprite would move 2.

    We may not want the sprite directly attached to the mouse- hence the offset parameter. Offset just specifies an x/y offset that can be any value. In MPong this is used as a "fudge" factor to make sure the Sprite lines up better with the mouse.

    This is one of the buggier segments in the Animator API. It's difficult to get the movements tracked properly- if the mouse moves too fast, the Browser might drop some MouseMove events- a critical problem if the mouse is moving out of the bounds of the game area. Hence fudge factors like "offset". Before the MMP starts providing, "registerMouse" must be called- in MPong, I call it relative to the BODY of the document- so all motions must be tracked that way. I attempted to tie it to MouseOut events as well- which would have allowed me to track it within the game area instead, but that just didn't work. Since MMP relies on the client positions and translates them to the containing element, this isn't a problem.

    Really though, MMP needs to be re-written before production use. It works well enough, but I wouldn't trust it not to break down if someone starts to do anything interesting with it.

    clock.js


    The Clock is very simple. It simply uses "setInterval" to schedule repeated callbacks to its own "fireEvent" method (imported via the EventSource Aspect). This is a nice event-driven clock, which makes it easy to tie the game functionality into it. There's not much there.

    Game


    MPong is a test-case for the Animator API. While a very simple game, it provides enough complexity to give a reasonable test of the Animator API. A few moments of play will reveal that it's not much as games go- dull, uninteresting without an uneven challenge level (the ball sometimes crawls, or builds up to ridiculous speeds). Despite this, it does a good job of demonstrating a realistic use of the Animator API, as well as some applicable design patterns.

    Paddles


    Paddles are merely raw Sprites. They are tied to an instance of the MouseMotionProvider class, and hence follow the mouse. There's nothing really exciting here.

    Ball


    The Ball is a bit more interesting. There's a few layers here- the Ball exhibits some complex behavior. It needs to bounce, detect when it's fallen out of bounds into the scoring area, etc. The bottom layer is the Sprite used to represent the ball. A few areas of the game directly interact with the Sprite- the Pong class is directly responsible for triggering its rendering process, for example. Instead of weighing down the implementation of the Ball with inheritance, I simply tracked two objects- the ballSprite and an instance of the Ball class. There's no strong relationship between these classes at all- the Ball simply wraps around any Sprite and provides Ball behaviors. It does not alter the prototype or the instance- it just operates on the Sprite's properties. In this, it's similar to the Decorator pattern, but without the strong ownership implied by the pattern.

    The Ball class owns a reference to the ballSprite, as well as its own private LSMP instance. Remember, LSMP works for any linear motion that can be represented as a constant vector. The Ball delegates all motion tracking to this provider and contains all the bounds-checking logic in itself. After letting the LSMP tell the Sprite where to go, the Ball checks that position- if the Sprite is impacting on one of the boundary walls (Left/Right), it reverses the sign on the LSMP's horiz vector component- "reflecting" the ball. If the ballSprite impacts on a paddle, it does the same to the vert component- again, "reflecting" the ball. Finally, if the ball hits a scoring area, it fires an event to announce this. It's the responsibility of the game to handle reseting the board. At the moment, I'm double checking the bounds, since it checks the bounds for every paddle. Again, for this application, that's not a problem, but with a large number of potential collisions, that could become very inefficient.

    Pong


    With all this functionality pushed into classes, all the Pong class really needs to do is make sure it's providing the key plumbing. It tracks a Clock, which tells it to render. It calls out to the Sprites, the Ball, etc. for all the logic. It simply needs to track the "globals" like the current score, register events, and so on.

    Problems


    In addition to a few of the problems I've discussed above, there's a few more serious flaws. It appears that on the first viewing of the page, the bottom paddle falls outside of the gaming area. Strangely, a refresh fixes that. Why? Why would a refresh even do anything? I'll have to track down exactly what's wrong there.

    There's also something wrong in the Ball motion logic- specifically something having to do with bouncing off the right wall- sometimes, and for no reason that I can determine (yet), it just sticks to the right wall and stops. I think it happens when the ball is moving too fast on the horizontal axis.

    The final issue isn't my fault, I swear. I left an early version of the page running in Firefox overnight. After 16 hours- it leaked memory like sieve. My system (Windows 2000- yes, I know) came down hard. There's really nothing I can do about that, and I can't imagine anyone playing this for 16 hours- but it's worth noting that it happens.

    Source: http://community.livejournal.com/javascript/135865.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home