Jump to content
xisto Community

gavacho

Members
  • Content Count

    6
  • Joined

  • Last visited

Posts posted by gavacho


  1. Don't expect to be making commercial games anytime soon. Game programming is not an endeavor for rookies. It is perhaps the most difficult and technically complex area of programming. I worked for a company that had a team of a dozen programmers working for a year to develop online poker software, and they failed and abandoned the project. I don't mean to discourage you, you can start simple, making practice games, until you develop enough skill for commercially viable products.Most online games are written eith in C++ or Java. C++ is the faster language and does not require any addons as does java. The advantage to Java is that game can run in the customer's browser without requiring a software download.Both C++ and Java are heavily Object Oriented or OOP languages. Your first step in learning game programming should be to learn how the OOP framework is used. A good place to start would be to browse the programming forums on this site.


  2. For a life-long sport, I recommend running. As you know, it is very healthy and aerobic, and it is also downright fun! You don't need any special equipment, only a good pair of shoes (and not even that, if you run on the beach as I do). And you can do it anywhere, at any time of the year (if the snow is not too deep). You can run to new places and explore, and soak in all the sights, sounds, and smells, of the world around you as you pass by. You can get into a comfortable rhythm where your body feels like a well oiled machine. And you will get high without drugs. The runners high that you get when you hit that zone is better than any drug experience.Running can also be a social activity. Running events are held everywhere in the world. If you are the non-competitive type, you can run with the local Hash House Harriers group, whose motto is "A drinking club with a running problem". It helps to be a beer drinking degenerate to fit in with this bunch. There are over a hundred HHH groups worldwide.Running will also help you get in shape for skiing in the winter. It is a sport that will last you a lifetime.


  3. A five minute introduction to PHPIf you are like me, you are intimidated by long, drawn-out tutorials that ask you to write a lot of code. I am a purpose driven learner. Any programming learning that I do is what is needed to accomplish a particular task, so I have neither the time, nor the interest in learning all the ins and outs of a programming language. In the case of PHP, trying to learn about all areas of PHP would probably require a lifetime, and it would be futile because the language is constantly changing and evolving. To me, the easiest way to learn a programming language is to just learn the very basics, then get right into using it for practical purposes, thereby learning by doing. This is easy because I have access to the internet, the greatest storehouse of knowledge, and greatest university that ever existed, right at my fingertips.So that said, take a look at your watch. You are going to learn all you need to get started with PHP in five minutes or less!First, lets open the sophisticated (not) software that we need to create our first PHP script, Windows Notepad. I use notepad because it is as simple as it gets, and is on every Windows computer, but any plain text editor will do. DO NOT use applications such as Microsoft Word to do any programming ever, because it adds hidden characters to files.In Notepad, type the line "This is my first PHP script" (with quotation marks), then, and this is critical, then save the file as myscript.php. This is critical. You must save it with the .php extension instead of a .txt extension. You do this by clicking the arrow beside the "save as" drop-down file type list in the Save dialog box, and saving it as "All files".At this point, you have a php file, but no way to view it, since a browser cannot open a php file directly. PHP is a server side scripting language (as opposed to javascript which is a client side scripting language). Therefore you need to have a server with PHP installed in order to view your php file. You can use a remote server with PHP installed to do this, but what I recommend is to test your files locally using a server installed on your own computer. You can install an Apache server on your Windows computer using a package called Wamp (http://www.wampserver.com/en/) which is free, and installs everything you need with one click, or use a similar package.Ok, now that you have a server installed, navigate to your file in the browser with your server running. You will see the text you typed. Now what you have is a PHP file, but it does not contain any php code, so it is not really a script. Let's add some php.First, type <?php on the line above your text in your myscript.php file.Then type ?> on the line below the text. All php code must go between these opening and closing tags. Try browsing to your file again. Now all you get is a blank page. In order to view text that is incorporated within a php script, we must use an echo statement. all we do is place word echo in front of the quoted line of text, and a semicolon afterwords. Every php statement MUST end with a semicolon (:lol:. Now the script looks like this:<?phpecho "This is my first PHP script";?>Now browse to it and you can see the text again. Note that any text strings used in php must be contained within quote marks. Alternatively, you could have placed the text as html code on the page, outside the php tags, like this:<?phpecho "This is my first PHP script";?><p>This is some html on the same page as the php</p>Were done!we have just learned enough to get started with php. This is because the entire php language is comprised of 100's (maybe 1000's) of built in functions that do all of the tasks that you need the language to do. All you have to do is choose the function you want, and enclose it within the php tags like so:<?phpphpinfo();?>This is a particularly useful function, because if you browse to it, it will display detailed information about your php installation.All other functions work the same way. Some require parameters between the parentheses, and others, like phpinfo(); don't.Where do you find all the nifty php functions? Download the php manual as a Windows help file from PHP.org, or leave the online version open in a window. There you will find all of the php functions, all you have to do is copy and paste the ones you need, along with everything there is to know about the php language.In this case the function used is phpinfo()but it could have been any of the functions.You can also write inline code in php such as:<?phpa = 2 + 2;echo "a";?>If you browse to a file with this code, the answer, 4 will be displayed.That's it! Everything you need to get started using PHP, the most powerful and easiest web scripting language.


  4. Does your site have good original content such as maps, photos, tutorials, or widgets? Have you noticed that your number of hits, and bandwidth usage has gone up, but your sales haven't? Check your server logs. If many hits are coming from a single URL for no apparent reason, maybe you should pay a visit to that URL. There's an excellent chance that you will find your content being displayed somewhere on that page. By using iframes or regular frames, another site can actually put your page on their site. By using tricks such as z-index, and CSS positioning they can even display only one part of your page, the content they are stealing.

    When another site displays your page or content on their site, it costs you bandwidth. It is a visit to your site from which you get nothing. It may not be regarded legally as stealing where you are, but it is definitely unethical. Fortunately, it is extremely easy to prevent. All you have to do is put this code snippet in the head tags of each page you don't want to be framed:

    <script type="text/javascript"> if (top != self) { top.location = location; } </script>

    This will turn the tables on the would-be framer, because now the page being framed will open as the top level window, and their visitor will be on your site! You will have turned a drain on your bandwidth into a great source of visitors at the thieving site's expense!

  5. Two areas of web development, CSS and OOP have been accorded the status of a religion, maybe even a super-religion by a large segment of the developer community. The syncophants of CSS and OOP worship at the temple of the W3C gods. Insult whatever is the religion of the last church they attended, and you may get just a shrug, but suggest it may sometimes be better to use an HTML attribute than a CSS style, or that it might be better to write a few lines of unique code inline instead of packaged in a class, and you will surely get a vociferous response.

     

    Once upon a time, some up and coming web developer, maybe this author, was called into the office of the Big Boss. On the boss' computer screen, the announcement of the major new product release was showing. It had a problem: the margin of one section of text was a bit off and it looked out of place and ugly. It was an announcement that had been created by a junior web designer under him, who had just quit for another job. " I called on you JD (maybe not his real initials) because Bill the department manager said that you're the best we have, and this is critical. The release of the new Omega package is Thursday this week we have to have that announcement up, but golly it's an embarrassment looking like that! I need someone I can depend on to get it fixed right away and I'm sure you're the man.

     

    Our hero, JD the web developer, left the bosses office with the big smile on his face walking on air feeling very elated that he would have the opportunity to impress the big boss and possibly even get a promotion and all he had to do was just fix a simple HTML mistake. JD wasn't really much of a web designer, he was more of a coder, but he figured this would be simple, so he went back to his office and confidently set to work.

     

    He started by looking at the generated HTML source of the page and found where the errant margin was. The HTML tag containing the offending text was styled by both an id attribute and a class attribute. He looked at the top of the page and saw that there were three stylesheets that were linked and two that were imported. JD did not know which of the stylesheets held the style he was interested in, so he looked at the first one. It was a jumble of style rules in no particular order that had been added over time by multiple developers. Finally, using text search, he found the class corresponding to the one in the offending tag.

    The bad margin that JD was trying to fix was 5 pixels too wide, so he changed the style to decrease the margin, saved the changes, and then took a look on his testing server. The margin had not changed, it was still 5px too wide! Perplexed but still confident, he closed that stylesheet in his browser and moved on to examine the next one for a clue for why the margin didn't change.

     

    Now those of you readers that have some experience with CSS and web design yourselves may have some inkling of the sad turn this tale is about to take...

     

    After spending the next hour examining the other two linked stylesheets, JD had found no other style that would influence that margin width. He was feeling less confident and starting to sweat, as he noticed the boss passing by in the hall, casting a concerned look towards JD's cubicle. Then it occurred to him, something he had seen but ignored in the first stylesheet he had examined: a class of the same name attached to an HTML selector! He made the change to this rule also, and he was so confident that this would fix the problem, and so anxious to finish the job for the boss, that he uploaded the revised stylesheet to the server without bothering to check it first on the testing server.

     

    Our hero did have enough sense to navigate to the page with the error in his browser after uploading the stylesheet. To his surprise, the margin was still off! It had not changed. He undid the change that he had just made to the stylesheet and uploaded it again. Being generally an optimistic sort, JD was looking at the bright side of the situation which was that he had not made the mistake of prematurely reporting the problem as fixed. He was taking a breather for a moment, sipping on a cup of coffee and considering the possibilities, when the head of his department, JD's immediate boss, Bill rushed in with a look of panic on his face and his voice trembling with fear "Every margin in the center column of every page of the site is messed up! The CEO is furious!"

     

    Like a bolt of lightning, it struck him: JD knew exactly what the problem was, and it was his fault. He had neglected to undo the first change that he had made to the stylesheet, before uploading it after the second change. Every page on the site used that stylesheet. JD admitted no culpability, merely feigning a slight look of irritation that implied that the problem was the fault of some subordinate. He was really hoping that somehow he could take credit for fixing this new problem and distract attention from the fiasco of the original problem.

     

    Soon it became clear that the big boss was not inclined to give anyone credit for anything at that point. He stormed into JD's corner office cubicle with the window that JD so coveted, and red-faced with his voice a couple of decibels louder than usual said, "I thought I could depend on you to get the problem with the announcement fixed. Nothing has been fixed, and there have been even worse problems! I just got a call from the CEO and he is very concerned about this". "Well, I did fix the big problem with the rest of the margins," JD ventured defensively. "Which never should have happened in the first place and is another problem with your department!" the boss blustered. At this point, JD is cringinging with fear and hoping that he will wake up and discover this is really all just a nightmare (maybe it is). In the meantime, real or no, he has to appease the big boss so he guarantees to have the problem fixed in one hour without fail. "Both our jobs may be riding on it" the boss replied.

     

    Now feeling very unhero-like, JD our web developer was working on the most important task of his professional career: he has one hour to shift a paragraph of text on a web page by 5 pixels. Wild thoughts of transparent spacer images, and wistful thoughts of how easy it would be to dump the CSS styles altogether and use simple, dependable, deprecated HTML techniques to align the paragraph where it is supposed to be. He knew however, that it would never get by the most feared employee in his department: The Validator. The Validator was a rather stern ex-schoolteacher whose job it was to check all work done in the department to ensure that the code validates against W3C and company standards. It would be so easy to ditch the CSS and simply use a table with a padding attribute instead, to position the text. So easy, but so impossible because such a deprecated constructs would never make it past The Validator.

     

    As JD's allotted hour was drawing short, he was getting desperate. He had compiled a list of all the styles in all of the linked and imported style sheets that he thought could possibly affect the text in question. He vaguely remembered something from his university days about how to calculate the order of precedence of CSS styles using statistics and mathematics. He was so absorbed in attempting this calculation that he didn't notice when the big boss walked in behind him. He was startled when the boss asked in a calm, worrisomely sympathetic voice that rose in pitch at the end to a threatening overtone. "When I get back to my office and I look at the announcement on the internet it will be fixed right?" At that moment, JD could sense that "No" was not an option so he lied, "Yes sir. All fixed, and I'm sorry it took so long," even managing a weak approximation of a confident smile.

     

    Now JD had approximately one minute to fix the problem and upload the fix to the server, maybe longer if the boss stopped to flirt with the cute secretary down the hall. He was so confident that he had just found the style rule that was causing the problem, that he uploaded the fixed stylesheet live to the internet, and holding his breath with anticipation, he navigated to the offending page with Internet Explorer. Hallelujah! It was fixed and he was saved! He called the boss to let him know the good news. In the back of his mind, he knew that he should have check the page in Firefox before calling the boss, but partly because of confidence in his fix, and partly through lack of confidence in it, he didn't.

     

    More jubilant than he had been in a long time, and now feeling like a hero again, JD heads for the door, leaving an hour early to have a celebratory cocktail or two at his favorite after work joint. He was intercepted by Bill his department head on the way to the door. "I'm sorry JD, I looked at your fix, and it works fine in IE but it's a disaster in Firefox. And, unfortunately for you, the Vice President (Big Boss) uses Firefox on his computer. You have until the end of the day to clean out your cubicle".

     

    Such tales are to be heard in the web programming world also, because there are strong similarities between CSS and OOP (Object Oriented Programming). Conceptually, CSS and OOP are almost identical. Both are means of packaging code in standardized, reusable packages. In CSS, the packages contain presentation rules, and in OOP, code. Even the terminology is similar because classes refer to these packages of reusable code in both instances.

     

    This object oriented concept has proved to be very valuable and successful when used for code or styles that really do need to be reused, but it is really the proverbial double-edged sword, because

    although it makes it very easy to make changes to multiple pages all at once, it can make it very difficult and dangerous to change just a single instance. Just ask JD in the story above.

     

    And how about styles or code that are only used in one place with no need for reuse? Should these also be packaged under the OOP/CSS framework? The W3C gods have decreed that practically EVERYTHING must be packaged in the OOP/CSS framework. It is blasphemous (deprecated) to use such a primitive structure as a table and only a bumpkin would ever write any inline code.

     

    Unfortunately, many developers take these commandments of the W3C to heart, regardless of how difficult or impractical they may be, and end up with code that is both much more difficult to write, particularly considering the need for cross-browser compatiblity, and also much more difficult to understand and maintain than necessary. If simple, proven, inline coding techniques are more appropriate for a unique task, why not use them? Loosen up W3C, make things easier, not harder (please do not report this article to the W3C, or the author will probably be stoned to death).


    Notice from rvalkass:

    Anything copied must be placed in Quote tags.

    Copied from http://www.toucanmultimedia.com/articles/pdf/article-330.pdf

    Please check out the Xisto Readme.


×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.