» Archive for the ‘Yahoo’ Category

Games & YahooSunday, February 25th, 2007

Solitaire - JavaScript version

SolitaireLong time since last post. I’ve played with SuSe 10.2, very nice distro, I had no problems with any application which I’ve tried to install on it. Also, I’ve made another JavaScript game based on YUI. I think, everyone knows what the word “Solitaire” means.Copule of years ago I wrote similar project in Delphi. The main feature of that application
was that the cards were automatically generated by functions implemented in the code. Instead of using 52 images which would represent each of the card I used only small pictures of figures,symbols and small images of king, queen and jack, the rest were done by specified functions.

The JavaScript version works the same.This is very controversial technique, It’s hard to say what exactly is faster and what is slower: loading one big image (16/8 colors GIF - with size 71×96px) or a few small images (2 colors GIF with size - ~15×15px). The answer is not that simple. However I choose the second way and this version of the Solitaire demostrate how that technique works.

Firefox and Opera are loading images only once; if, for example, two objects refers to the one image in the same document, then on the second time the image will be loaded from cache. On IE each image will be loaded separately, so if you’re using IE you will need to wait a little bit longer.

This also is a demonstration of YUI drag and drop techniques…

Enjoy…

Solitaire

No Comments »

Ajax & Games & YahooSunday, January 21st, 2007

Space Invaders!

My first contact with “Space Invaders” was about 6 years ago. It was an assembler version found in programmersheaven.com. I think this game is a grand grandmother of all space shooter games, look at the first release date - 1978. WOW! (four years older than me :)).

Couple of weeks ago I decided to create my own version of “Space Invaders”. The code was written by me but the sprites (aliens, UFO, laser gun) is taken from the original version. Everything is written in JavaScript, with the little (read big) help of Yahoo User Interface (same as the last two games).

I had the problem with Firefox, because instead of Opera and IE, in the Firefox the use of the processor while the game was running, was very big (maybe because that a lot of loops were running at the same time). So, I have to rebuild the first project and optimize it for the Firefox. However, still you can see some delay while aliens and UFO are moving (maybe it is some proof that the Gecko engine is slower than IE’s engine :/, no it can not be!). (If you have some time you can check which browser is faster, just turn on window.setInterval(); function (three or four different at the same time) with some loops (not infinite, you can change top and left attributes of some div elements).

This game also wasn’t tested in the Safari browser. Works fine in the latest version of Opera, Firefox, and IE.

Enjoy…

Space Invaders!

No Comments »

Ajax & Games & YahooWednesday, January 10th, 2007

Puzzle!

Making games (even simple games) is a challenge. The creation process is not very difficult and may be fun of course if you know what you are doing (or writing). When I have a new idea I’m asking myself if I know how to do it. This is very important thing! I have to be sure if I know how to make the key elements of the code, before writing any line I must know the algorithm which will describe these elements. So I’m making a few tests, searching for solutions on the internet, in books, or trying to figure out by myself how to create it. And the last step is writing the code (hmm, someone could say that is the first step).

Today I want to present my new project based on YUI library and Flickr API. I think the title say everything - PUZZLE. Each photo which you can find by searching Flickr, is divided in sixteen pieces and placed on the square board. All pieces are randomly set and the last piece is empty. All you have to do, is to set the pieces in their correct places by swapping empty piece with near placed pieces.

The hardest thing while creating this game was figure out how to divide images into pieces using only JavaScript. CSS give us very helpful attribute called - “background-position“. If you have image with size, for example 640×480 pixels, and you want divide it into 16 squares you have to do something like this:

640 / 4 = 160;
480 / 4 = 120;

  • .square1 { background-position: 0 0; }
  • .square2 { background-position: 0 160px; }
  • .square3 { background-position: 0 320px; }
  • .square4 { background-position: 0 480px; } - the last square on the first line
  • .square5 { background-position: 120 0; }
  • .square6 { background-position: 120 160px; }
  • .square7 { background-position: 120 320px; }
  • .square8 { background-position: 120 480px; } - the last square on the second line
  • .square9 { background-position: 240 0; }
  • .square10 { background-position: 240 160px; }
  • .square11 { background-position: 240 320px; }
  • .square12 { background-position: 240 480px; } - the last square on the third line
  • .square13 { background-position: 360 0; }
  • .square14 { background-position: 360 160px; }
  • .square15 { background-position: 360 320px; }
  • .square16 { background-position: 360 480px; } - the last square on the fourth line

This technique works well on a small images (640×480 or less), you can use it also with the largest images, however the loading time will be longer (especially in IE).

Have a nice puzzling! :)

Puzzle!

No Comments »

Ajax & Games & YahooThursday, January 4th, 2007

Yetris

Welcome in the new year. I spent the last three days writing another web application based on YUI (Yahoo User Interface). This time I’d like to present a very old and class game - Tetris, but because I use libraries provided by Yahoo I called it Yetris!.

I used same ideas, algorithms (maybe I should call this engine) from the code which I wrote 5 years ago. Check my post from September 22nd (2006), I showed then a simple Tetris game written by me in assembly language. The new version is written in JavaScript.

This time I look deeper in YUI documentation especially in parts that concern animation, DOM and Event, what I’ve learned you can see by playing this game (A lot or not much? :))

You can find exactly three animations:

  1. Intro - brick image fade in, zooming text,
  2. Game Over - falling lines fade out,
  3. Yahoo YUI logo - zooming while mouse over.

I tested this game in 4 browsers (Opera, Firefox, IE 6, and IE 7) and works fine, however some unexpected things may occur. I will be grateful for any feedback about how this game works in Safari browser.

Have fun!

Yetris!

No Comments »

Ajax & YahooSaturday, December 23rd, 2006

Image-Search

This time I used Yahoo Ajax to build my search engine. Yahoo provide more features than Google, and give us more opportunity to create better application. I’m only talking about Ajax, however with Yahoo we can build applications using Flash, .NET, PHP, Python, Ruby - see Developer Center for more information).

Google vs. Yahoo

Google Yahoo
Maximum 8 results per search All query results are available
Results can be loaded into specified container or we can manipulate on the array of results Response data is in XML format
- 5,000 queries per IP address per day
Web Search, News Search, Blog Search, Video Search, Local Search Web Search, Audio Search, Content Analysis, Image Search, Local Search, News Search, Site Explorer, Video Search
Custom Search Engine MyWeb
Google Ajax Search API Key Application Id
- Web Proxy for Cross-Domain XMLHttpRequest Calls
Only .setQueryAddition(term) method (for site:, link:, etc.) Building request with URL parameters

Yahoo providing more services and more products than Google, however it is much simpler to build application based on Google Ajax. This is because when we are using Google we don’t have to care about how results are formatted, we can use standard style and put the results into some container. Yahoo give us response in XML format, so first we have to read information from XML (Same with Google when we want to use information contained in array).

I like both solution, Google Ajax gives less but it is simpler, Yahoo Ajax gives more however we need to fight with XML (It is not that hard, but we have to do that). If you didn’t see my Custom Search Engine based on Google Ajax, look here, but today I would like to present my new project Image-Search based on Yahoo Ajax.

No Comments »