CHI TIẾT SẢN PHẨM
The models hold the game state and implement the game (domain) logic. Ideliberatedly kept the models isolated from the rest of the application, so thecode doesn’t know about the controllers or views, and also doesn’t need a DOM.This has made the code much more maintainable. I’m also hoping that it willhelp me when I write tests, perhaps with Mocha.
Contents
Log Data
In which I show how to harness jQuery UI’s Mouse plugin to roll your owndrag-and-drop handling, when Draggable is not flexible enough for you. I haven’t found it necessary to steem backed dollars derive either models or controllers from acommon base class. I’ve found that by doing a hackathon, I’m forced to just keep working,so I’m producing code all day. I’ve rarely gotten so much output from mybrain in one day.
Also, Ipicked up a lot of CoffeeScript and jQuery that I wouldn’t have beenexposed to otherwise. The past four months have been dedicated to working full time onBroccoli (blogpost), thanks tosome savings from my previous consulting gigs, combined with moderate livingexpenses. You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page. Our Service may contain links to other sites that are not operated by us.
DoubleClick Cookie
Starting a week from now, I will scale my open-source work back to part time,to about 1–2 hours per day. There is still work to be done on Broccoli as wellas related projects like ember-cli, but it doesn’t require full-timecommitment from me anymore. We may collect information that your browser sends whenever you visit our Service (“Log Data”).
Card Controller
Cards on the tableau need to be stacked by alternating color from high rank (King) to low rank (Ace). Empty spots on the tableau can be filled with a King of any suit. The goal is to move all cards to the four foundations on the upper right. There are many coordinate properties on the event object, but you should usee.pageX and e.pageY, which arestandardizedby jQuery to return the coordinates relative to the top left corner of theentire document. I’ll definitely do hackathons again.Being able to whip up a webapp on a whim is such a good feeling.
I have afeeling that there will a lot of issues with inconsistent browser behavior if Itry to do this myself, so I’m leaving it for now. To be honest, I’m finding that my game controller is becoming a sprawlingassortment of semi-related methods. I think this in part due to GUIs beingmessy business, and in part due to suboptimal design.
We use your Personal Information for providing and improving the Service. By using the Service, you agree to the collection and use of information in accordance with this policy. Cards on the foundations need to be stacked by the same suit from Ace to King.
You may move single cards or piles of cards within the tableau. You may only move cards off the waste pile, but you may onto and off the foundations. It would be sweet to handle touch events to make this work on mobile devices.Unfortunately, the Mouse plugin doesn’t support touch handling yet.
Solitr started off as a weekend project, but then Inoticed it started getting actual traffic. I knew that the highest-ranked sitefor “solitaire” gets over 100k dailyvisits, soI figured that with ad-monetization alone, there’s probably a business there. In addition, we may use third party services such as Google Analytics that collect, monitor and analyze this type of information in order to increase our Service’s functionality. These third party service providers have their own privacy policies addressing how they use such information. Say the user starts dragging horizontally at point 50, 50, with distanceset to 10.
About Solitr
A day or so into the rewritehowever, I was beginning to question whether Ember’s attribute-binding approachwas right for a game. Finally, in mouseStop, snap the element to the nearest drop point (orwhateverlogicyou want to implement), and update the application state if necessary. Sometimes you need tighter control over drag-and-drop logic than jQuery UI’sDraggable andDroppable plugins afford. For instance,when I wrote up the Solitr game, I initially usedDraggable, but I ended up with an unmaintainable mess of auxiliary “drop-zone”divs, and I also didn’t find the drop logic to be flexible enough for a game.
- I have afeeling that there will a lot of issues with inconsistent browser behavior if Itry to do this myself, so I’m leaving it for now.
- In retrospect, taking time off to write Broccoli was clearly worth it.
- By using the Service, you agree to the collection and use of information in accordance with this policy.
When thirteen cards of the same suit from King all the way to Ace are together on a tableau column, they are automatically moved to the foundations. (Incidentally, Draggable derives from this.) We can use thisto handle mouseStart, mouseDrag, and mouseStop events in a way that worksconsistently across browsers. But simply binding to mousedown and mousemove events yourself will cause aheadache because you’d have to work around subtle cross-browser compatibilityissues.
Business: Solitr
Eventually I will haveto split it into more classes, but for now it actually works quite well. So attribute binding and template updating are the two things I recommend youpay attention to when choosing an MVC framework. It means that when yourcontroller responds to an event, it only needs to update the model and everypiece of your app that (directly on indirectly) depends on it is notified. Pulling 18 hour work-days, of course, is rather not sustainable, let alone the20 real hours that it turned into. But when you’re writing an app from scratch,it’s only satisfying if at the end you have it actually working, socompromising on scope is not really an option.
Event Sequence
Runninga free-to-play game presents a unique opportunity to get my hands dirty, as Iget a ludicrous number of data points very early in my business – the kind ofdata that with a SaaS business you would only get at significant scale. Since then, traffic to Solitr has risen to 4000 daily visits (mostly throughranking for niche keywords), even though I haven’t been able to work much onit so far. Some testing with AdSense indicates that I can start paying therent with it. It also makes meconfident that once the search ranking improves, I can have a viable business.
- My role model for this is Patrick McKenzie– my Solitr is approximately equivalent to his Bingo Card Creator – and hisextensive blogging has been of immeasurable value to me.
- Personally, having Broccoli will help me with the upcoming work onmy business, and writing it has helped me become a better developer.
- The controller has to check whether a given action islegal in order to give proper user feedback.
- Changes to this Privacy Policy are effective when they are posted on this page.
I think the better alternativeis trying to get faster at creating new apps. Now that I know my way around thebasics of CoffeeScript and jQuery, I think I might be able to do the same thingin 16 hours, which seems much more reasonable. Perhaps I canmonetize it a bit by selling boutique consulting like Patrick. But moreimportantly, I’ll have a valuable tool for scaling businesses in myprofessional skill set.
Probably the most important feature in Ember is attribute binding. Itallows attribute changes to automatically propagate through all layers of yourapplication. I would like to thank Richard Hoelscher, who created an excellent vector version of Grimaud’s 19th-century “Paris pattern” card deck (see the archived page or download paris.svg).
Bình luận