|
-
IBM tunes up for Jazz open-source project
Date: 01/30/07
(Web Technology) Keywords: programming
Set to launch in June, Jazz aims to modernize development tools for programming teams that are geographically spread out.
Source: http://news.zdnet.com/2100-9588_22-6154727.html
-
Help!!!
Date: 01/30/07
(Algorithms) Keywords: programming
Hi, I'm new to the community. I study Graphics Design (this is my first year) but we started with Computer Science in general. I have no idea about programming and I don't get pascal at all... Can anyone help me with writing a program?
I'm supposed to create a program using Delphi7 (=> console type). There's a .txt file with a list of 4 students, the number of their grades and the list of the grades. The program should count the average of the grades for each student and then sort the names by the average, lowest to highest.
Kowalski Andrzej 4 3 3.5 4 3.5
Nowak Siergiej 5 5 3 4.5 4 2.5
Elfryda Ciupaga 4 4 4 3 4.5
Gertruda Cebula 3 5 4 3.5
I tried to do it myself but I'm a poor programmer. Here's what I came up, but most of it is probably wrong.
program Project2;
{$APPTYPE CONSOLE}
uses SysUtils;
const max = 20;
type
student = record end; ave = real; studentlist = array [1..max] of student;
var f: text; no, i : integer; sum : real; name : string; u : studentlist; N : 4;
begin assign(f, 'data.txt'); reset(f); for 1..N do u[i];
readln (f; u) name; readln(f, no); sum : 0;
for i:= 1 to no do
begin read(f, grade); sum:= sum + grade; end;
u.ave := sum/no; { TODO -oUser -cConsole Main : Insert code here } end.
If somebody can help me I'd be really grateful. I promise to study more on the pascal in the future.
Source: http://community.livejournal.com/algorithms/89292.html
-
Probably off-topic but...
Date: 02/05/07
(PHP Community) Keywords: php, programming, css, html, xml, asp, sql, java, web, google
As I look for alternative employment I see a lot of wanted ads asking for a web designer who are proficient in several web-programming languages (they usually specify PHP/ASP/CGI-Perl), the use of several different databasing formats (Access, SQL of some sort, Oracle) - proficient in several different forms of design (Photoshop, Flash, Illustrator, FreeHand, Quark, etc) as well as being a master of JavaScript, XHTML, XML, DHTML, CSS and any other acronym they seem to have found on google.
To me this sounds like they are asking for a web-design team wrapped into one person. Am I crazy; or are they?
Source: http://community.livejournal.com/php/538219.html
-
Galleries
Date: 02/10/07
(WebDesign) Keywords: programming
Just wondering if anyone happens to run an image gallery on their site (or any site) and if so would they be able to recommend a new program for that sort of thing. I already have two running with Minigal but with the two projects I have lined up, I just wanted to know if there are any other freeware programs out there, especially since in one case it doesn't quite fit my needs. Any links would be great.
Basically I'd like to save time on having to manually program thumbnails to images that have to come up in a pop-up window. For the other project the person does not want to be bogged down with programming so the less he has to do, the better (though I'd be the one setting it up for him).
Source: http://community.livejournal.com/webdesign/1219454.html
-
Kazaa's creators do latest venture by the book
Date: 02/27/07
(Web Technology) Keywords: programming, web
Joost, the new Web video venture of Niklas Zennstrom and Janus Friis, has struck the mother lode of television programming through its deal with Viacom.
The New York Times
Source: http://news.zdnet.com/2100-9588_22-6162401.html
-
How To Debug Execution Path in PHP…Equivalent of printStackTrace() in Java
Date: 03/01/07
(Java Web) Keywords: php, programming
While programming in PHP often you will find that a simple echo or log statement is not sufficient. You have found out where a problem is happening but you have no clue why it is executing that code in the first place. This is where execution path comes in handy. With a simple call you [...]
Source: http://blog.taragana.com/index.php/archive/how-to-debug-execution-path-in-phpequivalent-of-printstacktrace-in-java/
-
Эти люди пишут книги...
Date: 03/13/07
(Code WTF) Keywords: programming
Примеры найдены в Programming C# by Jesse Liberty (O'Reilly, 2003)
public double Pow(double x, double y){
double retVal = x;
for (int i = 0;i < y-1;i++){
retVal *= x;
}
return retVal;
}
private void Order_Click(object sender, System.EventArgs e){
string msg;
msg = "Thank you " + txtName.Text +". You chose " ;
for (int i = 0;i
(UPD: Во втором фрагменте - цикл по списку радиокнопок)
Source: http://community.livejournal.com/code_wtf/71967.html
-
Viacom videos still playing on YouTube
Date: 03/14/07
(Web Technology) Keywords: programming, google
Daily Show clips among copyright programming on the Google site a day after media conglomerate sued for $1 billion.
Source: http://news.zdnet.com/2100-9588_22-6167167.html
-
community site setup- opinions?
Date: 03/27/07
(WebDesign) Keywords: php, programming, css, web
Hi everyone, I was wondering what the best way to go to set up a community site. I'm set to inherit a local music-scene related website, or 'portal', that used to have a 'blog' of sorts on the front page with announcements from the administrator(s), a bulletin board for discussion and promotion, and a photo gallery where anyone who wanted could easily upload and display pictures they took at events. The old site was phpNuke powered and got hacked, and the old admin also simply doesn't feel like dealing with the site anymore, so it's currently on hiatus.
I was thinking wordpress perhaps? They have a new bbPress thing (from the makers of wordpress, a bulletin board that's code-light, customizable and skinnable, and standards-compliant) but I don't know what to do about a collaborative photo gallery; I think they used the coppermine in conjunction with the phpNuke before; I would like to have it so they could log in to the site once and use any of the functions.
I'm researching different options, and I'm pretty handy with webmastering, css-based design and some minor php-programming/tweaking, so that's not a problem. I would just like opinions on the best methods or open-source/cheap web-community resources.
Source: http://community.livejournal.com/webdesign/1236559.html
-
let's get semantic
Date: 04/04/07
(WebDesign) Keywords: programming, css, html, java, web
hello again buddies. thanks for the class feedback. and now a new question:
i design websites and i create them with CSS, HTML, javascript, a little server side, a little flash, etc. that makes me a web developer right? i don't really understand if there are formal definitions for "web designer", "web developer", or "web programmer". i'm just working on my website and i don't know if i should say "HTML and CSS programming" or "HTML and CSS development". i think development sounds better. but does development imply information architecture too? i don't always do that . . . does it make sense to say "Flash programming" and "CSS development"?
thoughts?
also, i always say i use HTML, not XHTML, when in reality i am using XHTML. does this matter?
Source: http://community.livejournal.com/webdesign/1240994.html
-
Jobs...
Date: 04/17/07
(PHP Community) Keywords: php, programming, mysql, software, browser, css, html, xml, technology, database, sql, java, jsp, web, linux, microsoft, apache
Moderator, if this isn't allowed on this forum just let me know.
I get a lot of emails daily for various web dev and programming positions available. I found a good job, but I keep my resume up. Ya never know.
Just feel guilty constantly deleting them when I know someone may need them. Figured I'd at least post them for any coder friends that may be looking for something. I lj-cut it so it wouldn't be too obtrusive.
If these are just found to be crap, let me know and I'll stop passing them on. But some of them at least appear to have potential. They're all fresh over the past 24 hours.
To whoever is currently looking, hope these help! If it's ok, I'll send periodic digests of these if anyone finds them worthwhile.
Hello,
I came across your resume and would to speak with you in regards to 2 immediate Cold Fusion needs in the Radford, VA areas.
Here are the details.
We need people onsite! 40 hour work week schedules
Location/Address: Radford, VA (Southwestern VA)
Start Date: ASAP
Drop Dead Start Date: ASAP
Project End date: N/A
# Of resources need for role: 1
Position Title: ColdFusion Software Engineer
BE Level/ Job classification: Consultant
Required Skill Set (Yrs Exp):
SKILLS: ColdFusion software developer with experience leading the development of software modules.
EXPERIENCE: Proven experience analyzing system requirements, guiding overall application development and individual module development. Direct involvement in application development, maintenance and operations of an application environment involving Microsoft SQL Server back-end with Macromedia ColdFusion middleware running on Microsoft IIS webservers.
Specific education and experience requirements include: 1. Minimum 4-year technical degree in Computer Science, Information Technology, or related field from accredited institution 2. Minimum 1 year general programming experience and an additional 1 year experience in web-based application development 3. Minimum 1 year experience with design, development and maintenance of ColdFusion-based online software applications 4. Practical experience in MS SQL Server (v7 or higher) database design, operations, and maintenance involving extensive structured query language (SQL) usage and development of complex queries and procedures 5. Practical experience with MS SQL Server (v7 or higher) database administration 5. Must be a US Citizen 6. Prefer current active Department of Defense (or capable of attaining) Secret Clearance
Preferred Skill Set
Will also consider candidates with Java and JSP experience.
Job#2
Location/Address: Radford, VA (Southwestern VA)
Background of Project:
Start Date: ASAP
Drop Dead Start Date: ASAP
Project End date: N/A
# Of resources need for role: 1
Position Title: Web Page Designer
BE Level/ Job classification: Sr Systems Analyst
Required Skill Set (Yrs Exp):
The candidates we are seeking should be self starters, interested in seeking new ways to help this customer innovate and provide state of the art web design capabilities to DoD customers.
Technical & functional requirements:
- 1-2 years ColdFusion development experience using Version 6.0 or 7.0 (prefer 7.0) - 1-2 years experience with Enterprise level database design including stored procedures and functions. - working knowledge of the Fusebox design methodology, using version 3.0 or higher to develop robust web applications. - proficient with use of Visual Mind software, version 7 - demonstrate ability to elicit requirement definitions from customers, then convert those specifications into realistic software development projects, and further develop a schedule in MS Project for task delegation and performance tracking. - US Citizen
Preferred Skill Set
XHTML or similar browser based scripting development, web services development experience a plus. - Cascading Style Sheet development using CSS v2.0 or later preferred. - Microsoft SQL Server 2000 database design experience preferred.
Please forward me an updated word copy of your resume and give me a call.
Thanks!
Ray Santos | 1-800-627-8323 x9509 | rsantos@mastech.com Mastech | 1000 Commerce Drive Pittsburgh, PA 15275 | Ph:1.888.330.5497 x 9509
Fax: 412-291-3037
Mastech respects your privacy. We will not share your resume or contact details with any of our clients without your consent.
Greetings!!!!!!
VIVA USA INC., (www.viva-it.com) is an IT consulting firm headquartered in Rolling Meadows , IL servicing clients nationwide. We specialize in IT, telecom, engineering Staffing Solutions and system integration
Please respond with your word document résumé, hourly rate, availability, visa status and relocation details to. recruit07@viva-it.com. One of our recruiters will get back to you ASAP. Kindly find below the job description.
POSITION : Web Designer
LOCATION : Columbia , SC
DURATION : 6 Months
Job Description : To create a new web site to replace the old web site.
Required Skills: Web Developer, Web Site Design, Dreamweaver
Optional Skills: .Net, XML
Sukanya
Viva USA INC, Chicago IL
Phone: 847-448-0727 Ext 207
Fax: 847-483-1317
www.viva-it.com
An ISO 9001:200 & CMMi M/WBE Company
I saw your resume on Careerbuilder and thought you may be interested in this opportunity. BMW Manufacturing is looking to hire a Web developer for some contract work in their Greer, SC plant. I’ve included the details below. If you are interested, or know someone who may be, please contact me ASAP. I look forward to hearing from you soon.
Sincerely,
Aaron C. Fisher Sr. Account Representative Information Technology Division Greytree Partners, LLC
(704) 815-1288 Office (704) 973-0767 Fax (704) 607-8518 Cell
aaron.fisher@greytreepartners.com www.greytreepartners.com
Entry Level – Web Developer Opportunity at BMW Manufacturing in Greer , South Carolina Client: BMW Manufacturing Job Title: Web Developer / Designer Assignment Length: 3 to 4 Weeks Shift: 1st / Full time Responsibilities: Update / refresh current departmental web content. Evaluate simple content management alternatives. Start Date: 23 April 2007 Estimated End Date: 31 May 2007 Required Skills: HTML Pre-Employment: Drug screen, background check (no education required).
I have an exciting opportunity available for a PHP developer. I know the location may not be ideal but I felt it would be worth a look.
Location: Las Vegas, NV
Length: Contract to Hire/Direct Hire
Rate: Depends on experience
Required Skill Set:
Extensive advanced PHP experience Back end PHP programming experience Experience with PHP 5 Experience with MySQL Strong understanding of advanced Object Oriented Programming principles is a must
For further consideration, please email your resume in Word format to cwander@yorksolutions.net.
Thank You!
Christi Wander York Enterprise Solutions cwander@yorksolutions.net
Good afternoon,
I came across your resume today on Monster.com and I have a position available that your skill set seems to match quite well. We are looking for a L.A.M.P. (Linux, apache, MySql, PHP) Developer candidate for a full time permanent opening in Toledo . This position is available with a great Online Bill Payment company, headquartered in Toledo and Washington D.C. This position is looking to go permanent in the 35 – 50K range, dependent upon experience. Ultimately, we are looking for someone with at least 3-5 years experience; comfortable in a lead type of role. If you are interested in discussing this opening with me, please feel free to email or call me at your earliest convenience.
I look forward to speaking with you soon,
Carl
Carl Saad Manager of Branch Recruiting T 734-462-9505 F 734-462-6443 csaad@otterbase.com www.otterbase.com
Hello! My name is Kristie Butler and I work for Procom Services, an IT Staffing Company. I am currently seeking a Web Designer for a 6 month contract position based in Columbia, SC. This position requires the following:
The client is lookikng to create a new web site to replace the old web site. They are a Windows Department and they are looking for a public and private side (logon) in Web site. This will be a temp position, possible temp to hire position.
Required Skills:
Web Developer Web Site Design Dreamweaver Organizational Skills Written Communication Skills Adobe Photoshop Windows XP .Net XML
If you feel you possess these skills and you are interested in this position, please send a current word document of your resume to kristieb@procomservices.com.
Thank you!
Kristie Butler Procom Services 1-800-678-4590 kristieb@procomservices.com
Source: http://community.livejournal.com/php/561562.html
-
PHP magazines & blog suggestions
Date: 05/29/07
(PHP Community) Keywords: php, programming
Part of my morning ritual is to run through the following php and related sites:
Anything else out there thats educational/useful?
Source: http://community.livejournal.com/php/568391.html
-
5 Tips for Bulk Data Processing Programming
Date: 05/30/07
(Java Web) Keywords: programming
We are currently processing huge amount of sensitive corporate data for a Fortune 500 company as the first phase of a project. You have to be very careful in data processing, much more than any standard programming effort. Here are few tips you may find useful when programming to process sensitive data in bulk. Get [...]
Source: http://blog.taragana.com/index.php/archive/5-tips-for-bulk-data-processing-programming/
-
Need some assistance in writing up SQL Server tasks for resume
Date: 06/03/07
(SQL Server) Keywords: programming, database, sql
I'm trying to update my resume with the sql server tasks I've been doing for the last 2+ yrs, but I'm really stuck on what exactly to put and how to word it.
Quick background: I've heavily programmed in and used MS Access since 1994. In many cases, I did the db design, creation, and upgrades for all tables, queries, forms, and reports. I often created the app that other people use. It took me a while to find a job where I could learn and use SQL Server. I finally found that about 2.5 years ago (there's a lot of Access programming using a tool already created at my company, with a SQL Server backend).
Could really use some input!
I'm really not performing SQL Server DBA work; the majority of the tasks I tend to perform are: - writing and running simple select queries
- writing and running complex queries (several inner and/or left joins) to select, append (insert into), update, or create a new table from a data set using particular criteria
- processing/manipulating large data sets (1 million + records) to drill down to a smaller set that can be handled by the Access app
- incorporating CASE statements into the queries
- importing a table into SQL Server from text files, spreadsheets, or Access tables, using the Import/Export tool (a task I do only very occasionally)
Any suggestions on how I can word this in the resume?
Oh, and I can tell you as an experienced Access programmer (who started from v2, where you had to really understand Access and database concepts and normalization, no cute little wizards to help) that SQL Server really ROCKS and I prefer it. Now, to be able to use it more...
Source: http://community.livejournal.com/sqlserver/59901.html
-
YouTube signs licensing pact with Hearst-Argyle TV
Date: 06/04/07
(Web Technology) Keywords: programming
Revenue-sharing deal will pay local TV stations when users of the video-sharing site watch their programming.
Source: http://news.zdnet.com/2100-9588_22-6188383.html
-
HELP - problem finding errors
Date: 06/08/07
(PHP Community) Keywords: php, programming, css, html, database, java
Hi there,
i'm having a problem with a site i'm working on. i'm a media student and one of our many subjects is system design, meaning we learn about java, python, php and more languages. i'm not the programmer person, and the subjects i like better in my studies are the design ones, so natuarlly i'm having major problems understanding and doing programming.
i know that i'm not the worst in it either, but with this exercise i've come to my limits. it's pretty simple. we started with making a layout using css, but then we had to add php code and a database to it so as to add new elements and edit existing ones to the database using forms.
so, the problem is a general and ususal one, meaning that there are errors in my code that i just can't find. i've gone through it a million times, asked collegues to give me their code to compare (since they didn't have time to sit down with me and help) and i've gone to message boards to ask for help (which wasen't very successful cuz they directed me to go read some basic php tutorial. i wouldn't have gone to the message board hadn't i done that already). anyway, i'm at a total loss as to what could be wrong. the zip file uploaded here contains everything of the page, even a text file of the database used that you can import into your server.
the problems i have are:
1) the 'DVD-Vols.php' file should just print out all the dvd volumes that exist of the series. beside each entry is a delete link to delete that entry from the database and a link to more detailed info on that dvd volume. the printing works out fine, but the delete link only deletes the entry of the database table that has the 'ID' '0'. the link to the detail info does not work either. i wanted use a php codeing that automatically fills in the 'ID' to it's corresponding entry in the db and passes it on, so the detail page of the dvd (DVD.php) knows which dvd volume to display.
2) on the 'DVD.php' page i want to print out only one of the table entries from the db, depending on the 'ID' the link from the previous page passes on.
3) the add and edit forms (there are two versions of each: Add-Form.php & Edit-Form.php) don't seem to work. a friend of mine told me they are correct, but when using them on my machine, nothing happens. what happens on mine regarding the add-form was the following:
i had started my table entries with an entry that i gave the 'ID' '1' to instead of '0', so when using the add form, the new entry was assigned that id. when trying to add another, the previous entry i made lost all it's 'contents'. the edit-form did not work at all.
4) in the home.html page i'm trying to add an image that moves from one side to the other, which seems to only work when first loading the page (it moves 5px to the right) but somehow the counter seems to not work, and i've got no clue why.
i know that this is a lot to ask, but i'd REALLY appreciate the help, on any of these problems.
thanks a million in advance!
[x]cross posted
Source: http://community.livejournal.com/php/570094.html
-
BBC, Yahoo invite developers to hack Web apps
Date: 06/17/07
(Security) Keywords: programming
Hundreds gather in London to see what some imagination, programming skills and very little sleep can do for companies' media apps.
Source: http://news.zdnet.com/2100-1009_22-6191518.html
-
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
-
whole row comparison
Date: 07/08/07
(MySQL Communtiy) Keywords: programming, mysql, sql
Short info: Is there a way to use a * operator in a query like so:
`SELECT newSrc.*, oldSrc.* FROM current_raw_table newSrc LEFT JOIN yesterday_raw_table oldSrc ON(newSrc.id = oldSrc.id) WHERE newSrc.* != oldSrc.*);`
to use mysql to compare two tables of data created by a `load data infile` where one table is today's and the other is yesterday. My tests with using *'s failed so plan B is to use my l33t programming skillz to generate a bunch of `if(newSrc.{fieldName} != oldSrc.{fieldName},"fieldName") as "{fieldName}",` then wrap the whole mess with concat_ws(' ',...);
but before I use said l33t skelz, I figured it might be smart to ask before I reinvent something else.
Source: http://community.livejournal.com/mysql/116735.html
-
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 ComponentsCore 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.jsThe 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.jsMovement - 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
|