Inspiration, Motivation, and Fools Gold
I am fairly fond of the title for this post as it does two things. It’s an open invitation to spam crawlers and this is the first blog post in some time with more than a code snippet or two.
In short, it has been almost a year since I’ve graduated Full Sail University and since then I have had a number of experiences that made me on numerous occasions question the validity of my life-choices. This stems from the idea of immediate sacrifice and delayed gratification towards a brighter and happier future. This for most is an accepted part of life and being successful. While ultimately we all strive for happiness and each time we sacrifice and give we hope it to be a means to an end. Of course as we grow older we slowly but surely realize the real cynical nature of human life.
I’ve asked myself on occasion; what makes me happy? Is it having a high paycheck? Is it the process of creating video games? Is it sitting at a bar? While I’ve questioned my motives, I always arrive at the same answer sooner or later. I realize that I simply wish to be challenged and learn. At the core that is what drives me! That is what motivates and inspires me. Still I’ve never been able to make the jump to a full time Indie, or a commit towards academia.
In the near future I hope to reevaluate why I have failed to follow my real agenda. Attain courage, and achieve some closure.
This is essentially a slightly longer twitter post. Thanks for reading.
Wordpress Pagination
Today while striving to wrap up Michael Kofman 2009 I found myself spending longer than I would have liked trying to get a “wordpress page” to loop through all of my blog posts with enabled pagination. The intention was to become familiar with the wordpress framework, install a few plugins and be on my marry way. Sadly things didn’t quite go so smoothly. So to make this a lot less painful for future readers here is a short list of steps and plug ins used as well as a final code snippet. After I’ll discuss some of the alternate methods I found, share my work cited and hopefully put some value into the community.
Wordpress Page Templates
My first question was how to create a new page in wordpress and apply to it my own layout and stylesheets. This was incredibly easy and intuitive.
- Create a new .php page that will serve as a template for your new wordpress page.
- Page templates are easily recognized by the wordpress CMS via a magical comment.
1 2 3 4 5 | <?php /* Template Name: Your Template Name Here */ ?> |
- Navigate to /wp-admin/ and depending on the version of your dashboard click add page.
- Here you can give your page any title you want. And somewhere on the page you should see an option to apply a template to the page (again this varies with wordpress versions so Google or check documentation). If you uploaded your new .php template to the proper location you should conveniently see “Your Template Name Here” as an option.
Installing a Pagination Plugin
I decided to use WP-PageNavi although there are several alternatives I’ve found.
To download and install follow these instructions:
1. Download WP-PageNavi
2. Upload folder “pagenavi” under wp-contents/plugins
3. Activate the plugin
4. Add the following code into your current theme’s php file.
5. Configure the settings under WP-Admin -> Options -> PageNavi
6. Click “Update Options” and you are done.
The Lonely Loop
The reason I titled this lonely loop is because most wordpress documentation will refer to the post entries as “THE LOOP“. The final code snippet that finally got things rolling for me was as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; $my_query = new WP_Query('showposts=5&paged=$page'); $wp_query = $my_query; query_posts("showposts=5&paged=$page"); while ( have_posts() ) : the_post() ?> <div class="post" id="post-<?php the_ID(); ?>"> <div class="date"> <div class="day"><center><?php the_time('d') ?></center> </div> <div class="month"><center><?php the_time('F') ?></center> </div> <div class="year"><center><?php the_time('Y') ?></center> </div> </div> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php the_content('Read the rest of this entry »'); ?> <p><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> </div> <br class="clear" /> <br class="clear" /> <?php endwhile; ?> <div><?php next_posts_link('Older Entries')?></div> <div><?php previous_posts_link('Newer Entries')?></div> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> |
Obstacles Overcome
One of the first challenges I faced was realizing that the default loop provided in index.php did not properly render posts but instead interpreted function calls like the_title() with regard to the title of the page (template) opposed to individual posts. I later found according to slightly misleading documentation that a new query object is required. I proceeded to create one called $my_query. Where I would prefix function calls as such.
$my_query->have_posts()
and
$my_query->the_post()
This seemed to work, but the next problem was getting pagination to work in synch with this new query. The problem was that WP-PageNavi only listens to $wp_query. I had wondered around for some time trying to resolve this particular delima short of writing ajax and the pagination functionality by hand or maybe trying a different plug in. Thank fully after jumping from link to link I finally stumbled onto the following code block.
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=5&paged=$page"); while ( have_posts() ) : the_post() ?> <h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2> <span class="entry-date"><?php the_time('F d, Y'); ?></span> <?php the_content(); ?> <?php endwhile ?>
This finally got the ball rolling. I had only correct a few errors that sparked from the constant experimentation like a random reseting of the query at the end of the while loop. Conveniently above the pagination caused the current page to always read 1.
Hope this will be helpful to someone in the future. Here is an unordered list of sources.
http://codex.wordpress.org/Template_Tags/query_posts
http://codex.wordpress.org/The_Loop
http://codex.wordpress.org/Function_Reference/WP_Query
http://codex.wordpress.org/IRC
http://almosteffortless.com/2006/12/21/wordpress-pagination-on-a-page/
http://jarodtaylor.com/blog/wordpress-ultimate-archive-index-with-pagination/
http://www.w3cgallery.com/w3c-css/wordpress-pagination-in-pagephp-or-display-subpages-as-paging-under-parent-page
http://wordpress.org/support/topic/256899
http://www.lesterchan.net/wordpress/readme/wp-pagenavi.html
Getting Started with wxWidgets
I wanted to explore what wxWidgets was all about after learning that tool programmers in the game industry commonly use it in their development environment. Getting started with wxWidgets on a windows platform is fairly straight forward.
Download the latest stable release http://www.wxwidgets.org/downloads/
Go ahead and grab wxMSW – installer for Windows. Make sure your visual studio is closed so that the environment variable gets set up correctly.
Next your going to need to compile the library. So go ahead and navigate to installDir\build\msw.
Open up wx.dsw and convert it to your native Visual Studio format. Close visual studio back down and open up each vcproj in the current directory through notepad or notepad++. Search and replace each of the following:
– RuntimeLibrary=”3″ with RuntimeLibrary=”1″
– RuntimeLibrary=”2″ with RuntimeLibrary=”0″
Once your done. Open up the solution again, and right click the solution in the solution explorer. Select Batch Build. Select only the release and debug for each project. Once complete your ready to create your first wxWidget application with the added work of including all the directories and .lib in your project settings.
Here are two good links to help you get through this:
http://wiki.wxwidgets.org/Compiling_WxWidgets_on_Windows
http://wiki.wxwidgets.org/MSVC_.NET_Setup_Guide#Project_Properties
If it doesn’t work out right, go ahead and triple check everything!
What I learned from all this was that while wxWidgets are great for multiplatform development they are probably not a solution for developing game GUIs. I’d love to hear what others think on this subject, meanwhile I’ll move on to setting up my own GUI framework after a few hours of sleep.
New Sandbox
During a casual conversation someone brings up the idea of writing their own game engine. This is usually met rather stern remarks about complexity, lines of code, and a unworthy endeavor. Well for the most part I would say that is a true statement, and let me just say that is not what I’m trying to do. Well I’m trying not to think about it that way. My goal over the course of this week is to assemble together several sub systems I’ve done before, and some that I haven’t into a comprehensive sandbox. Then split it into several plug and play DLLs that I can use in future projects.
What I have so far:
- Math Library
- Event Handler
- Win32 Framework
- Resource Manager
- DirectX Initialization and Callbacks
What I’m tackling this week:
- GUI Framework
- wxWidgets Integration
- Network Framework
- Console Debugger
My Full Sail Experience
What drove me to take the plunge?
After high school I was very frustrated by the core classes that defined the first two years of a regular University. I was becoming even more frustrated by the partying, and lack of vision most of my friends and peers were only concerned about. I don’t remember what conversation made me remember Full Sail but it was a school I had known about since middle school and I truly felt my passion was in game development. I decided that I want two things out of my career. First interesting and challenging work that would keep me ever interested. Second I wanted to work at a fun place that allowed for creativity. So long story made a little shorter, Full Sail University is one of two schools at the time that might hope to provide for the sort of education that really teaches you the internal workings of making a game. I took the plunge. I packed up everything I owned into my car at the time 1998 Nissan Maxima, and drove it from Philadelphia to Winter Park FL. Thankfully my apartment was ready; I choose to stay at Winter Park Pointe apartments because they were the closest and cheapest in the area. I also decided to not have a roommate after a few disappointing attempts. So for the next few months I slept on nothing but a mattress.
The first three months are crucial at Full Sail; they help separate those who can and cannot handle the program. Odd schedules that have classes end at 1am and start again at 9am the next day. It was interesting trying to adapt to it, and many of us became nocturnal. The next month the schedule changed again. Oh yes, a semester is only a month long and classes are 40 hours a week. The pacing was perfect for me and I really dug all the knowledge. I was excited to be there, and I was just amazed at the different types of people I was surrounded by and all of whom held a strong interest in video games. I bought a PS3, and started playing games a lot more than ever before in my life. At some point along the way I think I lost sight of my goal and what was at stake. After the first three months I felt like I had C++ down solid.
The rest of the year we spent learning MFC, Win32, C#, DirectX, and Design Patterns. Along the way we also had a few general education classes needed for accreditation, but they too were all geared towards Game Development. This included an English course that had us write a full game design document. Math in Linear Algebra, Calculus, and Physics all laid out the foundation for what was to come.
The first game making experience was defined by two classes; Software Game Development and Software Game Production. I feel like both experiences deserve a post mortem but the lessons learned cannot be learned from reading this.
After the half way point it felt like we did something really great. We made a game! A great one at that. I, Casey Flach, and Charlie Prouse put together a 3D top down shooter in a roughly five weeks. Who knew that making a game doesn’t take months but weeks? Well we were hungry for more knowledge and the next few months more than helped satisfy that appetite. We took classes in Artificial Intelligence, Networking, Machine Architecture, OpenGL, Optimization, and Engine Development.
And we finally made it … final project… to be continued….