tag:blogger.com,1999:blog-1749100630513152812024-03-21T03:52:10.494-04:00Java DevelopmentI am a long time C++ programmer. The customer wants to go to the web. Time for me to learn Java.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.comBlogger123125tag:blogger.com,1999:blog-174910063051315281.post-34492681025071185862016-02-23T16:34:00.001-05:002016-02-23T16:34:05.929-05:00Back to Java<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuVgDu_HwHVEkvihrk6ZpvfgrSV4XT0e-SVfRVNxCQdIUfg-CONsZTlgdbg8LqrUao25tPdkeW5um5rU4m8f32rWNwVbRR3YGoyqvWFlBQLYgRerK0Q9ZBX8WgsAXxGZ3yhTS9fgNY5hA/s1600/H2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuVgDu_HwHVEkvihrk6ZpvfgrSV4XT0e-SVfRVNxCQdIUfg-CONsZTlgdbg8LqrUao25tPdkeW5um5rU4m8f32rWNwVbRR3YGoyqvWFlBQLYgRerK0Q9ZBX8WgsAXxGZ3yhTS9fgNY5hA/s320/H2.jpg" width="320" /></a></div>
I did a bunch of analysis on my last project. The customer wanted more project management. So another guy on the team had to take over, My boss told me to work on a prototype for some data input screens from a legacy system.<br />
<br /><br />
Some of the screens are huge. And they have complex validation logic. I fired up my text editor. Wrote some HTML and JavaScript to get the first screen done. That intro screen was small, but it had a ton of validation.<br />
<br /><br />
My boss called me up and checked on my progress. He clarified that he wanted me to use Java, Derby, AngularJS, REST, and JBoss EAP. He said some acceptable alternatives would be Oracle, HTML5, and Eclipse/Tomcat. I went with his recommendations.<br />
<br /><br />
I got JBoss Dev Studio with EAP installed on my new laptop. Then I started going through a tutorial from JBoss called Ticket Monster. I was following a pretty detailed tutorial. Things got vague when I was instructed to deploy the H2 console. Err what?<br />
<br /><br />
H2 is an in memory database. I went over to the JBoss <a href="http://www.jboss.org/quickstarts/eap/h2-console/">Developer Materials</a> page. Downloaded the zip file with the H2 console. Unpacked it and found the "h2console.war" file. Dropped that in the \runtimes\jboss-eap\standalone\deployments folder. Now here I am.<br />
<br />Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-74106361624177618262015-04-22T13:12:00.000-04:002015-04-22T13:12:19.916-04:00JBoss Developer Studio<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPqgxxuXSRbkG11iJpyaACYSAtDxn0Z1zl_J2c2GXqwrhD9ina2ehCDN0hXEr9Ezg8_ZNhb8GJrygEEqCoHp4fpCRArleyrsPdn_OUvzfHzyUU1BCkCLPLIZnaLLhNwEmJLQXbFFxio5s/s1600/JBossDevStudio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPqgxxuXSRbkG11iJpyaACYSAtDxn0Z1zl_J2c2GXqwrhD9ina2ehCDN0hXEr9Ezg8_ZNhb8GJrygEEqCoHp4fpCRArleyrsPdn_OUvzfHzyUU1BCkCLPLIZnaLLhNwEmJLQXbFFxio5s/s1600/JBossDevStudio.png" height="207" width="320" /></a></div>
At work I am starting to spend half my time on a new project. It is an effort to create a web version of our system. It will use the same Oracle back end. However the front end will be developed in Java using JBoss Developer Studio.<br />
<br />
JBoss Dev Studio is a rebranded Eclipse IDE. I know Java. However I always use a text editor to force me to learn the syntax and member functions of classes I use. So I am not well versed in Eclipse. This is going to be a long learning curve.<br />
<br />
One thing I found out is that if you have a workspace open in one instance of JBoss Dev Studio, you cannot open it in another instance. Makes sense I guess. But I fought with that for a while before I figured it out.<br />
<br />
I also learned that you may need to refresh your source tree for any changes in packages that your source supports. Go figure. Finally I found that I installed my software in the wrong order. I initially installed JBoss Dev Studio first. It then made me choose a JRE. Then I installed the latest JDK I wanted to use. Unfortunately I had to figure out how to reconfigure JBoss Dev Studio to use the JDK of choice.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-19072573961207355792015-03-27T10:53:00.000-04:002015-03-27T10:53:26.652-04:00Foiled by MySQL Connector/J Again<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6wCQwE7jFK5fW-_t-eerpUPZUC0TPsCyVtKOlUhoO4_O2T1Wsp5ACP1eziX1U0190Xft7HFK_lZv_roCtbrLJCu_xT1VmeK4F0m3iZO__Ut__7fpcCkVz0ycOnJnR4rr9TCPrldruqJI/s1600/MySQL.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6wCQwE7jFK5fW-_t-eerpUPZUC0TPsCyVtKOlUhoO4_O2T1Wsp5ACP1eziX1U0190Xft7HFK_lZv_roCtbrLJCu_xT1VmeK4F0m3iZO__Ut__7fpcCkVz0ycOnJnR4rr9TCPrldruqJI/s1600/MySQL.png" height="228" width="320" /></a></div>
All right. I dumped a lot of emails from Amazon to a text file. I parsed that file and have a lot of thousands of Amazon Kindle books that I own. Now I want to add them to a database. I want to stick them in MySQL specifically. So I call on JDBC to do the deed.<br />
<br />
I run into the dread error "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/". Now I have received that error before. I thought the solution was to stick the JAR file with the MySQL JDBC driver in the class path. Nope. That did not do the trick.<br />
<br />
For a while I was pulling my hair out, trying to figure this out. Then I went back to an old project where I got this working. Turns out you need to explicitly path the JAR file in the classpath. I had thought you only needed to specify its directory. No. You need the fully qualified path including the JAR filename in the classpath. Go figure.<br />
<br />
At least I got a boatload of book titles inserted into a MySQL database table. Now for the really fun part. Time to write a program to find the books on Amazon's web site and scrape some details out.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-51831082042681797982015-03-26T22:22:00.001-04:002015-03-26T22:22:24.789-04:00Web Scraper Revived<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZW96rh8x3_GFrxRn2_MVoQpVSYNQcudCNkgB0g9mks2ga0LPRwmZwWGuc0nB0BH6CKq1Ied7oB33ANG-qhb9NpDftPl48EBQttftw7Yrp6oEPW1gcQgaLiuGYq1lRmfvMqaQGxFV6WOc/s1600/Amazon.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZW96rh8x3_GFrxRn2_MVoQpVSYNQcudCNkgB0g9mks2ga0LPRwmZwWGuc0nB0BH6CKq1Ied7oB33ANG-qhb9NpDftPl48EBQttftw7Yrp6oEPW1gcQgaLiuGYq1lRmfvMqaQGxFV6WOc/s1600/Amazon.jpg" height="204" width="320" /></a></div>
Previously I had written about my web scraper <a href="http://enableassertions.blogspot.com/2014/06/mysql-connector-j.html">project</a>. Well now I am coming back to it. I got a couple thousand eBooks in my Kindle reader. It is tough figuring out what book I should read next each time I finish a book. I manually go through a lot of books, looking up their pages on Amazon. Wouldn't it be nice if I had a program that could help me decide?<br />
<br />
First order of business was to get a list of the books. At first I thought I might be able to hack the AZW file format and extract details from the books themselves. Nah. Too hard. Instead I remembered I had an email from Amazon for just about every book I bought. The emails were in Microsoft Outlook 2010. Turns out I could just save the emails as a text file.<br />
<br />
Now my first job is parsing this file. I was hoping to get the links to the books on the Amazon site. Nope. That is not stored in the text file output by Outlook. That is okay. I can get the book name. Next I need to figure out how to take that name and programmatically search the Amazon web site for details on the book.<br />
<br />
I plan to store my data in a MySQL database I got running on my machine. Right now I extracted all the book names to a text file. Next steps is to instead stick them in a database table. Maybe I will also record when I ordered the book. Then I will want to find and scrape the Amazon page for the book. Good things to grab from Amazon would be book price, date published, author, average customer rating, number of customer reviews, etc. All these goodies could be stored in my database.<br />
<br />
Eventually I want to write a function or program that could score the books, predicting which books I should read next. Ahh this is going to be a very fun project indeed.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-55395834124370404242014-08-04T23:51:00.000-04:002014-08-04T23:51:11.111-04:00Pacman Progress<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhacrUvu7IGEenmGJJXi8vKP-bktIj1JL2qIVUqGQ0mAhII-71WeTZS2M5YHr1gJztj5Sh0PMj2Fl0V3ZRoQvePQkOOjWUFkEdmqphMAdcwTdBLwVLBWBELn_jyEQQxh5aXM3RhoxhMoy0/s1600/Pacman.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhacrUvu7IGEenmGJJXi8vKP-bktIj1JL2qIVUqGQ0mAhII-71WeTZS2M5YHr1gJztj5Sh0PMj2Fl0V3ZRoQvePQkOOjWUFkEdmqphMAdcwTdBLwVLBWBELn_jyEQQxh5aXM3RhoxhMoy0/s1600/Pacman.jpg" height="218" width="320" /></a></div>
I am nearing the end of my summer project. This is a clone of Pacman written in Java. I think I will stop implementing new features. Just clean up the code. Fix some bugs. Package the thing and call it a summer.<br />
<br />
Recently I did a bad thing. I deleted all my Java files. I wanted to delete all my class files. That will teach me to try to compile from the command line. Damn. At least I had a backup that was a week or two old. It still irked me.<br />
<br />
Some buggy object code had the game crashing when exceptions were thrown. Now we still need to hunt down the root cause of those bugs. However I managed to keep things running by validating parameters passed into my functions. Prevents evil access problems.<br />
<br />
Next thing I might try to slip in there is better timing for the action in the game. Right now I just sleep a hard coded number of milliseconds based on how much processing I figured I expended to render a frame. However I really should just poll the clock to figure out how long to sleep.<br />
<br />Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-70692783783116033352014-06-21T01:21:00.002-04:002014-06-21T01:21:45.950-04:00Hot Technology<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLHnCtZ-8qj3J0MyYVEyiOSgU7Vkr0Z16y1fLvGrlCM7fItAUTWIgEkVFiKgMl5TAHMmaY6xEIW1MevMtaJBMxaj16tux4vFnRiFtCS1tALhVe6EIEd3jEgGLnjdfs8FisWHnC8YTTg08/s1600/Technology.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLHnCtZ-8qj3J0MyYVEyiOSgU7Vkr0Z16y1fLvGrlCM7fItAUTWIgEkVFiKgMl5TAHMmaY6xEIW1MevMtaJBMxaj16tux4vFnRiFtCS1tALhVe6EIEd3jEgGLnjdfs8FisWHnC8YTTg08/s1600/Technology.jpg" height="216" width="320" /></a></div>
I read an article that surveyed what technologies Java developers were using. Hey. I want to keep up with the Jones. So I am keeping an eye on the top tech in a number of areas. I write them down here so I don't forget.<br />
<br />
JUnit for testing.<br />
Eclipse as your IDE.<br />
MySQL or <a href="http://ora-pl-sql.blogspot.com/">Oracle</a> for the database.<br />
Hibernate is your ORM.<br />
MongoDB for NoSQL.<br />
Jenkins for CI.<br />
Maven to build.<br />
SonarQube/FindBugs/Checkstyle for code analysis.<br />
Nexus to hold artifacts.<br />
Tomcat app server.<br />
Spring MVC is your web framework.<br />
Scala is your next language.<br />
Java8 is coming up.<br />
<br />
Okay. Time to get busy making sure I got these technologies under my belt. You got to work with the best, or at least the most popular. Shout out to the makers of <a href="http://zeroturnaround.com/software/jrebel/">JRebel</a>, who I assume came out with the report ranking the technologies.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-85181448176561995772014-06-20T01:09:00.000-04:002014-06-20T01:09:27.688-04:00Wakka Wakka<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIFPK9TsJXScv3Q_l_ixSgiXJ5hEmP5Cbh-T3SpVyvSdOy91diKfQUaTF4uAsWateUcNxVBGgAoj0jBmP8EA7Ji1DyUiij4BwmqylkSvzZKaUQJffxN2xJIwNqKt_Xg4CHfmpfc_woUg4/s1600/Clip.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIFPK9TsJXScv3Q_l_ixSgiXJ5hEmP5Cbh-T3SpVyvSdOy91diKfQUaTF4uAsWateUcNxVBGgAoj0jBmP8EA7Ji1DyUiij4BwmqylkSvzZKaUQJffxN2xJIwNqKt_Xg4CHfmpfc_woUg4/s1600/Clip.jpg" /></a></div>
This week we are taking our video game to the next level. The prototype works good. I decided to make a number of noteworthy additions, including sounds. I had used sampled clips before in Java. I even knew the libraries I needed to include.<br />
<br />
So Pacman chomps on a pellet. The game is supposed to make this wakka-wakka sound. I got an audio file that has the sound. Just got to play it each time Pacman goes over a pellet. The first time I tried it out I heard nothing. I figured this could not be right. I played sounds before for my last game.<br />
<br />
Then I looked at my game loop. For now we are settling for choppy animation until we get all the mechanics down tight. To prevent the game from running too fast, I sleep() for a second each iteration through the game loop. Turns out you cannot play a clip and sleep immediately afterwards. Drat.<br />
<br />
When I finally implement the full animations, hopefully the sound will play fully. For now I just moved my sound playing earlier up in my game loop, giving it some time to execute before the thread sleeps. Next up my partner has to add more AI to make the ghosts "smarter". Currently Pacman can outsmart them and leave them lost.<br />
<br />Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-21174153318901035062014-06-17T00:20:00.001-04:002014-06-17T00:20:25.459-04:00MySQL Connector J<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw-pQDGX971oNNYrkc9tI390V5Tej4ewhAt7F31GwikK7_e7bToL3nuHTJd_71mpF7UB7DEwOa2TWTaDSHbA8IjwHy1yoanlHAFBIoNySxlEuLdJFR2Z0Kydknrw0TfSkCfkSXdSzO23s/s1600/JDBC.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw-pQDGX971oNNYrkc9tI390V5Tej4ewhAt7F31GwikK7_e7bToL3nuHTJd_71mpF7UB7DEwOa2TWTaDSHbA8IjwHy1yoanlHAFBIoNySxlEuLdJFR2Z0Kydknrw0TfSkCfkSXdSzO23s/s1600/JDBC.jpg" /></a></div>
My latest project is an Amazon web page scraper. I have almost 5k eBooks in Kindle format. Every time I finish reading a book, I have a hard time choosing the next one to read. I do a lot of searches on Amazon to figure out which of the books I own is the next best.<br />
<br />
I figured I should be able to let the computer choose a book for me. To do that, the computer needs to have a lot of stats on the books I own. Time to mine the Amazon web pages for those books to get the data I need.<br />
<br />
So I am working on a scraper to grab the data I need from Amazon web pages. Then I plan to store this data in a MySQL database. With all the facts on hand, I am sure I can write a function that ranks the books in order from best to worst.<br />
<br />
Writing the scraping portion turned out to be a big pattern matching exercise. Check. Next I need to store the scraped data in the database. I thought I had coded some Java that accessed a MySQL database. Turns out it was Java that accessed a Java DB.<br />
<br />
No problem. How hard could it be. Well I kept getting exceptions stating that there was no suitable driver found to access MySQL using JDBC. Err it turns out I need the MySQL Connection J jar file in the classpath. Who knew?<br />
<br />Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-46476806436544334782014-06-12T00:54:00.000-04:002014-06-12T00:54:42.308-04:00Pacman Fever<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBUpfbmXN7UePqothz36jEnXy2xI1X23UTQfR2U2jG_8FxX_0x1QjcOnAibPPwkTY2NDxxRSgyKfUN40qECuAmxOO0ZzjV_8nckzVVGqeCyqPxiUy6xF1qupVsAUbxZeJwaD7ZgeUYZ-E/s1600/Pacman.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBUpfbmXN7UePqothz36jEnXy2xI1X23UTQfR2U2jG_8FxX_0x1QjcOnAibPPwkTY2NDxxRSgyKfUN40qECuAmxOO0ZzjV_8nckzVVGqeCyqPxiUy6xF1qupVsAUbxZeJwaD7ZgeUYZ-E/s1600/Pacman.jpg" height="140" width="320" /></a></div>
I partnered up with a friend of mine from school to work on some projects together. At first we did some database web apps in PHP. Now we are getting to the real fun. We are writing a Pacman clone.<br />
<br />
Now I believe in starting small. Therefore I got Pacman to be drawn to the screen. The guy chomped around a rectangle nicely. My friend took on the task to get a ghost drawn. It drew, but ran off the screen initially. Bugs have since been fixed and the ghost bounces around inside the boundaries.<br />
<br />
Next step is to draw a rudimentary maze and have the Pacman and ghost obe the walls of the maze. I think we got this.<br />
<br />Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-21123489844023785412013-08-02T16:35:00.000-04:002013-08-02T16:35:58.112-04:00Custom Tools<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibUPiZNuSYpNjwc_mFtVQxHkhlfi18qKpjvEpevAIxckpLq8cue7aNgNJ_yajcbNrvfz-1nW6Ye4fxRWCEgtfULZ-ozeu0uYxzpxhgR6W1zwRHQmIJNsID4WoqH6jlv5KaAgii5vzZ_GE/s1600/JDBC.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibUPiZNuSYpNjwc_mFtVQxHkhlfi18qKpjvEpevAIxckpLq8cue7aNgNJ_yajcbNrvfz-1nW6Ye4fxRWCEgtfULZ-ozeu0uYxzpxhgR6W1zwRHQmIJNsID4WoqH6jlv5KaAgii5vzZ_GE/s1600/JDBC.png" /></a></div>
<br />
I was called by my boss to work on a tough problem. The previous developer spent a week on it and got nowhere. Great. Now the pressure was on. I was given a day to figure things out. So I got down to business. Had to try many things to replicate the problem in a development environment.<br /><br />
Sometimes I needed to update configuration data in the database. Most of the time I had to run some queries to figure out which values needed to be updated. Or I needed to run some specific pieces of some jobs, which turned out to be stored procedures. I figured there had to be a speedier way to do all this.<br /><br />
There is a better way. Create a tool to automate what I need done. What better language to implement this tool than Java? Figured I would use the easiest database access method I could think of. That would be JDBC. Unfortunately the last time I played with JDBC, I used it with a MySQL database that was running on my computer. Now I needed to access an Oracle database running on some huge server.<br /><br />
Luckily most of the ideas in JDBC transcend specific database choice. Just had to figure out the connect string. Turns out I could use an OCI driver that made use of a TNSNAMES alias. That was sweet. Took a while to get it working though. The real breakthrough came when I read the release notes for my Oracle 11g client that was installed locally. Turns out I needed to ensure a JDBC jar file was in my classpath.<br /><br />
My initial cut was a little slow for each action. That's becuase I was creating and closing out a session every time a task needed to be executed. Instead I need to refactor this to reuse one database connection that gets established when my tool starts up. That should be an easy enough fix. I wonder whether it is time to share my little tool with the other developers on my team?Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-27172221364731424872013-04-22T16:41:00.001-04:002013-04-22T16:41:52.692-04:00Right Tool for the Job<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi18DHY3mDxxFdC_aon7-hO4rQjRWepgRqNyKSx41vlMp9iCwpMxgYxGeZgtbjNcj9dU_DgJGo_jh1SOWnLVTBp65C9CMXcNo5vZuzE8DYDZyb21aFHj6gVL6nAZJNEYg6iueWN4orMaPA/s1600/Scraping.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" dua="true" height="182" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi18DHY3mDxxFdC_aon7-hO4rQjRWepgRqNyKSx41vlMp9iCwpMxgYxGeZgtbjNcj9dU_DgJGo_jh1SOWnLVTBp65C9CMXcNo5vZuzE8DYDZyb21aFHj6gVL6nAZJNEYg6iueWN4orMaPA/s320/Scraping.jpg" width="320" /></a></div>
I am dealing with this game system that cannot handle too many views to the ranking system. Sheesh. What is a developer to do? Scrape the screens, reengineer the data, and put up some new pages. That's what. I already grabbed the HTML output from a bunch of ranking screens. Now I need to parse through the heavy HTML and extract the raw data. Java is my tool of choice for this task.<br /><br />
I got a bunch of files. And I have studied them to learn the pattern of how the web pages are laid out. Now I need to go through the HTML, line by line, and grab the raw data. Luckily each page seems to fit a pretty well defined pattern. I just need to teach my Java code to read for the data like my own eyes can now.<br /><br />
Heck. Maybe I will even write the new implementation using Java. The original product was written in PHP. I suspect they have a MySQL backend database. For my first try, I plan to grab the data and stick it in an Oracle database. However it could just as easily work with a MySQL database.<br /><br />
The only question is that once I have an optimized replacement system, what language will I use to serve up the data? PHP? Java? Or maybe something else. For now Java seems best. I actually don't know PHP. So that is a main consideration.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-15764254510771418502012-06-13T22:23:00.001-04:002012-06-13T22:23:50.712-04:00Calendar Ease<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7FGt5qPPdQc4HEfZtw_D8n5btGXCHCgeEajJHvuTN9lVzwwHUIaivUCmO-FU4Dw-CCLxdNhWBXlzGq5CRAiiSeSkfxt0TyZJass5iZUnSEWCRQBDYe5Wb-aEKl7EnouXqTea72fnmB6c/s1600/Calendar.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"><img border="0" height="320" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7FGt5qPPdQc4HEfZtw_D8n5btGXCHCgeEajJHvuTN9lVzwwHUIaivUCmO-FU4Dw-CCLxdNhWBXlzGq5CRAiiSeSkfxt0TyZJass5iZUnSEWCRQBDYe5Wb-aEKl7EnouXqTea72fnmB6c/s320/Calendar.png" /></a>I have been writing some toy programs to relearn my Java skills. This time around I decided to write a calendar app. Nothing fancy mind you. I just put out a text calendar to the console.<br /><br />
Initially I had visions of computing all kinds of dates. I thought I could start with a known day falling on a certain day of the week. Then I could compute all relative dates with some formulas. Sure I would have to deal with leap years and such. But that would be a great project.<br /><br />
I found that the Calendar class in java.util was almost all I needed. No need to compute the day of the week the first day of the month falls on. I just set up a Calendar object with that date. Then I interrogate it to figure out which day of the week it is. Same thing with determining the number of days in a month.<br /><br />
This exercise was quite useful. I got some practice. I also learned some details of a new class. Calendar feels like a nice API. You just have to learn some of its constants. Then you can get() or set() to your heart's content. I banged out my calendar app in about 50 lines of code. Given that I am a bit wordy with my code, that is not too shabby.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-37560212452681205342012-05-31T03:44:00.000-04:002012-05-31T03:44:57.217-04:00Case of the Blank Screen<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCWrX-rhLneFtQDnTBkHmzePa8VMSpbgwEt-vmkw91RPA7YAfzZgZmWrGoPbseiCpOYYazmq_fCxsxNwh2iN5lDxlYxxuThZUIJ_oTz5ykEPOmjat5QyUfi6OaqsvxieEsyKckDbPRdUU/s1600/Spiral.jpg" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"><img border="0" height="240" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCWrX-rhLneFtQDnTBkHmzePa8VMSpbgwEt-vmkw91RPA7YAfzZgZmWrGoPbseiCpOYYazmq_fCxsxNwh2iN5lDxlYxxuThZUIJ_oTz5ykEPOmjat5QyUfi6OaqsvxieEsyKckDbPRdUU/s320/Spiral.jpg" /></a></div>I decided to continue my Java graphics programming with a simple program to draw a sprial. This should have been a cake walk. I kept in mind that the Math functions took angles in radians. My mind thinks of angles in degrees. The Math package can convert between the two units. For some reason, my graphics were not showing up on the screen. This was frustrating. A good developer know how to debug these things.<br /><br />
I output my coordinates to the console. Everything looked fine. Coordinates were getting further and further away from the center. Looked like the drawLine funciton was just not producing any output. I did all my drawing in a loop contained in the paintComponent function. I tried sticking some hard coded coordinates in my drawLine call. No change.<br /><br />
Then I moved over to the Graphics2D world. The draw function there did not work either. I did eventually make a breakthrough. Calls to drawLine outside my loop worked. WTF? Loops should not matter. And the output was good. I saw it on the console. Finally it hit me. I was initializing all my variables in the JPanel constructor. The loop stopped drawing when the lines went off the screen. My problem was that paintComponent was getting called more than once.<br /><br />
The first call to paintComponent worked fine. It also output the correct coordinates to the screen. However the subsequent call(s) to the function erased the screen. By then the variables had incremented past the point where they could be viewed on the screen. I guess I need to learn how to run the code in real time in a debugger. This is a little tricky with graphics programming, as I would need to see the graphics being drawn in real time as well. Sounds like a need for some type of graphics debugger.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-61441806607314493722012-05-29T01:41:00.000-04:002012-05-29T01:41:26.418-04:00Getting Rusty<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX7gQlG8N720YExtODCHknQurc4hZFEbYZrL1XOMyWesrIXtjLka01HrSTV61hwoEcYrVxJLcDDGkXT66r0ydNvyvgJZ3PhV1ZqYo-mObHtNRjafFd-PDqg3BwHxT6qp4RcTjO96KUiNU/s1600/Rolodex.jpg" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"><img border="0" height="192" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX7gQlG8N720YExtODCHknQurc4hZFEbYZrL1XOMyWesrIXtjLka01HrSTV61hwoEcYrVxJLcDDGkXT66r0ydNvyvgJZ3PhV1ZqYo-mObHtNRjafFd-PDqg3BwHxT6qp4RcTjO96KUiNU/s320/Rolodex.jpg" /></a></div>I spent the last semester learning the basics of <a href="http://xmlhome.blogspot.com/2012/03/form-alignment.html">JavaScript</a>. I promised myself that afterwards I would come back to the Java programming language. And here I am. I find that I have become a bit rusty in my Java programming. It has only been half a year since I knocked out some impressive Java programs. This was disappointing.<br /><br />
I broke out an old notebook that contained ideas for programs I wanted to write. Figured it would provide some inspiration for some practice Java programs. I started with an Address Rolodex program. It was nothing special. I had to relearn some of the GUI programming tricks I picked up last semester. Luckily I had to look up a few specifics. I recalled some of the tricks after a while. For example, I knew it was easiest to implement the ActionListener interface with my JFrame object. That way I coud just addActionListener(this) to set up my events. Much simpler than separate or inner clases.<br /><br />
The mechanics of storing my addresses were simply an ArrayList. Had to make a couple design decisions, like figuring out where the latest address you added goes in the list (I chose the front). I started getting a prototype down with a FlowLayout that looked terrible. All the controls were all over the place depending on the size of the window. At the end, I decided to use a BorderLayout. It does not look awesome. But at least the rows and columns line up nicely. That's because each part of the BorderLayout is a JPanel containing a GridLayout that does the dirty work.<br /><br />
Now I need to choose project number two. I figure I have all summer to relearn the Java skills I have deep down inside somewhere. I was even contemplating picking up a community college class to use to drive my Java coding. A friend mentioned such a class she is taking next semester. I checked the schedule of classes and found it only meet during the day. Us nine-to-five types cannot register for classes like that which interfere with the work day.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-61834696222869668242012-03-16T23:33:00.002-04:002012-03-16T23:38:02.841-04:00Object Oriented Programming<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE75Gq2It_zJDQzoOGA4bhyphenhyphenNWjPUxBHQNPPVuEjGsa6d5fI2HWZyOiT9LMuJVhmU5EQyNyyJN_kDeqfbH5A3BsnKHnvlKPYt-uYqZCN5wlOIUbn62H0BjkWYkJTWLxV0N5IOEQPFdXpn8/s1600/OOP.gif"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 265px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE75Gq2It_zJDQzoOGA4bhyphenhyphenNWjPUxBHQNPPVuEjGsa6d5fI2HWZyOiT9LMuJVhmU5EQyNyyJN_kDeqfbH5A3BsnKHnvlKPYt-uYqZCN5wlOIUbn62H0BjkWYkJTWLxV0N5IOEQPFdXpn8/s320/OOP.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5720704151574520754" /></a>When I was setting up my game engine, and even when developing my game, I took the time to create a nice class hierarchy. It took a little extra time. I did not go overboard. There may have been 15 classes tops. And some of those were small subclasses.<br /><br />During a final round of testing, I found some of the text was coming out wrong. That was disturbing as the text worked fine in some scenarios. I traced it back to find some code doing extra work to get the job done right. To fix the global problem, I moved that code to a base class. Then everyone got the fix. I did have to tweak a few instances where the specific code made some wrong assumptions. But I essentially fixed the problem in one location. Bonus.<br /><br />As an aside, I find the Java Collections Framework very helpful in developing games. Now I cannot imagine how I lived without them. Oh yeah. I used arrays. Painful. Luckily there is no more of that pain in my projects.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-14677306736682640732012-03-15T00:14:00.002-04:002012-03-15T23:36:55.932-04:00JDialog to the Rescue<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVo2rtfm1PmOAhyphenhyphenmmEDLGbLriGaj5ASYZWPGaW94Dy8LT9dhQ7_2cCv4cX9pQH0uEAy73gn1TwXElSzH6kdFu17dw1BpxPwHlZc4bUZgF05Yy2LZnCRsZfMa_uFO6JHMMKmQHhoPA51NE/s1600/JLabels.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 162px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVo2rtfm1PmOAhyphenhyphenmmEDLGbLriGaj5ASYZWPGaW94Dy8LT9dhQ7_2cCv4cX9pQH0uEAy73gn1TwXElSzH6kdFu17dw1BpxPwHlZc4bUZgF05Yy2LZnCRsZfMa_uFO6JHMMKmQHhoPA51NE/s320/JLabels.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5719972683057761874" /></a>I had a requirement to display a list of choices in a window. Furthermore I wanted the dialog to be dismissed as soon as the user pressed a key. Turns out the JDialog was the class I needed. Mapped the keys of interest to a listener and I was good to go. But then I needed to handle the display of the dialog.<br /><br />I must confess that I really did not have that much experience with JDialogs. Found out that it defaults to a BorderLayout. For my application, I needed more of a GridLayout. I surveyed a bunch of code on the web while searching for my solution. Learned that I could call the pack() method to size the dialog with the minimal amount of space required to fit the contents.<br /><br />I had one hiccup where I wanted to map the keys with the JRootPane. Thought I needed to do that when I created the JRootPane in createRootPane(). Unfortunately that method gets called from the superclass. I could not pass it any data. That's okay. I found I could later call getRootPane() and handle my business.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-88872185539075159652012-03-13T23:18:00.003-04:002012-03-13T23:25:41.595-04:00All About the Keys<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQW7Qytlp696ky7bMKr6ROAGja9BqM3DOf8GipIEVtyc8lmR-A7EnTnqvEJQXth0he881yu2yS_vIw884bx6ZL3y_Varu45-wbBW_DgXsShKb_zyP3UjJrToDAM2CJm43gj7bSTLEQCfg/s1600/Keys.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQW7Qytlp696ky7bMKr6ROAGja9BqM3DOf8GipIEVtyc8lmR-A7EnTnqvEJQXth0he881yu2yS_vIw884bx6ZL3y_Varu45-wbBW_DgXsShKb_zyP3UjJrToDAM2CJm43gj7bSTLEQCfg/s320/Keys.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5719587107614028434" /></a>I wanted to provide an easy to use interface in my latest program. At times I put up a dialog where the user must choose a value. I want the user to be able to just press one key to make the choice. Initially I tried using the JOptionPane. But it required the user to press enter after making the choice.<br /><br />I thought I needed to somehow specify an option (no pun intended) for the JOptionPane to just require a keypress. After a while, it felt like I was <a href="http://black-of-hat.blogspot.com/">hacking</a> to much to get this to work. I seemed to need to set some weird user interface options, then set up some maps, and I was still struggling to figure out which key got pressed.<br /><br />Then I researched some mneumonics. Turns out those require you to press the Alt key along with the choice you make. No good. Finally I figured I needed some custom code. I forgot about the canned JOptionPane and started concentrating on a straight JDialog. Got an assist from the <a href="http://www.java2s.com/Tutorial/Java/0240__Swing/JDialogisspecifythatpressingtheEscapekeycancelsthedialog.htm">Java2s</a> web site. A map plus a listener was all I needed. Now I am going back to the basics of drawing some user choices on the dialog. That should be a snap. I wish I knew to go straight to the JDialog in the first place. I been spending most of the day on this issue.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-51886797634490394702012-03-12T21:05:00.002-04:002012-03-12T21:11:09.682-04:00Anatomy of a Framework<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn3vqW3QVv_1E-NojZ_-BEBxtGgy00t5x8r477cEG8zVRttLozDAhJY1NwykI3uib2J08B7qBulG1nnq0D3Z342JTWJcXzS6sb5y9qRnBYgNArOWTNcSepm3mUyLdvx5Dq71hJ_V5TCGo/s1600/Framework.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 213px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn3vqW3QVv_1E-NojZ_-BEBxtGgy00t5x8r477cEG8zVRttLozDAhJY1NwykI3uib2J08B7qBulG1nnq0D3Z342JTWJcXzS6sb5y9qRnBYgNArOWTNcSepm3mUyLdvx5Dq71hJ_V5TCGo/s320/Framework.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5719181756806052322" /></a>I have known for a while that I was going to use Java to develop a game to enter this years <a href="http://legend-angband.blogspot.com/2012/03/7drl-2012.html">7DRL</a> contest. The last time I tried using Java to compete in such a contest was disastrous. I did not know how to do any graphics. That puts a cramp in your game development abilities. This time I was going to be prepared for a strong showing. Therefore I started working on a gaming engine well in advance. You could call it a framework.<br /><br />I figured I could just use a toy app to develop, mature, and test my framework. That worked out pretty well. I got some good code written and tested. The problem was that the framework became highly coupled with my sample application. Now that I am trying to make use of the framework for the real thing, I find myself ripping out the example code to get at just the engine.<br /><br />Note to self: create an API that is truly separate from any demos. That way I will be ready for reuse. I guess I need to put that to the test early as well. I should have created a second sample app that tried to use the framework. The issues would have been clear from the beginning.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-71202769740962166592012-01-25T10:38:00.002-05:002012-01-25T10:47:33.005-05:00Acronym Hell<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWTWoN9ocsYMB3SRVNNLgNtrKsOYBGRGeDCAmJEJrfzZ8Pq6MbcAEZkEo7fh8D-FokKsYAzhcCSTHv-wLkL3D9pAuxNtSifaE5hSZiwI7Hk_XU9SXDkja6pWpp8yr_lsmkRK3l0ODjpU4/s1600/JSF.gif"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 199px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWTWoN9ocsYMB3SRVNNLgNtrKsOYBGRGeDCAmJEJrfzZ8Pq6MbcAEZkEo7fh8D-FokKsYAzhcCSTHv-wLkL3D9pAuxNtSifaE5hSZiwI7Hk_XU9SXDkja6pWpp8yr_lsmkRK3l0ODjpU4/s320/JSF.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5701594668619351074" /></a>I just saw a massive blog post on developing a web app. Not only was the length of the blog post long, the list of related technologies was large. The post is going to hit JSF, CSS, EJB, DAO, JPA, JAAS, MVC, and MySQL. I have done a little bit of web application development. But I did not recognize all these terms. I guess you got to keep up.<br /><br />So far I have only checked out the first piece of this blog post. I plan to go through the whole thing. This just seems like a lot to take in to do web programming. Then again this makes web developers more in demand if the skill list is huge.<br /><br />The question I keep asking myself is whether I want to get into all this. The pain would be that the technologies would become obsolete or replaced just as soon as I master them. Such is life I guess.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-15959882370095564222012-01-24T22:15:00.002-05:002012-01-24T22:18:03.109-05:00Move to JavaScript<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXxVgxd7B-NUzulWn6Rp47HKq6tdgqWcIuUvYfyBhyphenhyphenf_QfYI1yGAKjGjW4lnuhj__m44APqtk05iVl6uMtTaqdy0wsnXRV5yavjzdOANwqV6t68NhLPuJQPTStl9WDkT0crZqga_9LwvE/s1600/JavaScript.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 258px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXxVgxd7B-NUzulWn6Rp47HKq6tdgqWcIuUvYfyBhyphenhyphenf_QfYI1yGAKjGjW4lnuhj__m44APqtk05iVl6uMtTaqdy0wsnXRV5yavjzdOANwqV6t68NhLPuJQPTStl9WDkT0crZqga_9LwvE/s320/JavaScript.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5701403025490698130" /></a>I have been sick for the last few weeks. So my Java roguelike game engine has been put on hold. That's okay. I shall enter a contest around March of this year to develop a game with the engine. I suspect I shall be doing a massive amount of Java coding that week. The engine will get some bug fixes and updates as a results.<br /><br />The Spring school semester is just about to start up. I am taking an intro JavaScript course this time around. I plan to stop my Java learning for a few months to concentrate on the JavaScript. By summer I should be back in full swing with Java develoopment.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-10673473717035791802011-12-20T20:48:00.002-05:002011-12-20T20:53:28.021-05:00Refactoring Complete<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCB_tojd9X3JkvhtlXdeW09UDYkZ-6oU1geRY0TjoBzBqz757HyiQEcwr2a6GQyL_Mn-G9y7EB8kpkGeaMUtMv6Eyhp-dvn8n9yfGU8HdyjhkelF3-Y_LtraR5pESr4CtkI3qK89JfkXo/s1600/Refactor.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 294px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCB_tojd9X3JkvhtlXdeW09UDYkZ-6oU1geRY0TjoBzBqz757HyiQEcwr2a6GQyL_Mn-G9y7EB8kpkGeaMUtMv6Eyhp-dvn8n9yfGU8HdyjhkelF3-Y_LtraR5pESr4CtkI3qK89JfkXo/s320/Refactor.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5688392873532629938" /></a>I had previously coded up a bunch of library code for my roguelike game engine. My first idea was to hold all items in a big array. When the items were picked up and them wielded, the item state would change. Then I had a bunch of custom code that switched on the state.<br /><br />The problem was that most items get removed and regenerated during change of dungeon level. I did not want my players inventory and equipment to disappear when the dungeon level changed. So I needed a refactoring. I decided to create separate containers for the player inventory and the player equipment. Today I refactored all the code to use this new design.<br /><br />I was pleased to see that much code was simplified. Many functions were no longer even needed. The code was getting really clean. This must mean the redesign was a move in the positive direction. This shall also allow easy changes of inventory/equipment rules in the future.<br /><br />Not sure what I am going to do next. I am still riding a high of a good code refactoring. It is probably time to implement some more functionality in the dungeon.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-21819852694871884812011-12-19T23:57:00.002-05:002011-12-20T00:01:21.125-05:00Storing Items<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr5Vc9r1TzmzqIRD-AqV_azKFNGknBxzpBXRhxfruGifZskroVzmtQb9MbaQeajyAhpUg7rx_lnrEW_IHr_3mYT9BLGu-SRfsKb2betIrdv6M5RuOy9NoxvZQnT3ZgxSfEc2-k4oiF_9c/s1600/Equipment.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 268px; height: 193px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr5Vc9r1TzmzqIRD-AqV_azKFNGknBxzpBXRhxfruGifZskroVzmtQb9MbaQeajyAhpUg7rx_lnrEW_IHr_3mYT9BLGu-SRfsKb2betIrdv6M5RuOy9NoxvZQnT3ZgxSfEc2-k4oiF_9c/s320/Equipment.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5688070295363643554" /></a>I am building a library to help with the development of a roguelike game. Got the maze generation down pat. Next I added items such as weapon and armor to the maze. I implemented these items in a big array. The items knew where they started out in the dungeon.<br /><br />As the player picks up and wields the items, the items change their location. This was working like a champ. Then I realized the items were tied to the dungeon. The dungeon gets regenerated on each level as the player walks up and down the stairs. Ooops.<br /><br />I don't want the players to lose the items in their inventory or on their body when they navigate the dunegon levels. What I should have done is to separately manage the dungeon objects and the player inventory/equipment. Then I could move the items from each of these containers as the player picks up or discards the items.<br /><br />This design change will require some refactoring. While I am at it, I might as well change the containers from arrays to lists. That will make the adding and removing a whole lot easier.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-65368085666187349322011-12-14T23:56:00.002-05:002011-12-15T00:03:52.134-05:00Maze Mechanics<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBBJzlrVxyas1a1reiyoYpSn7nYiSNrwPU0P90BJx8oyx-OJ-3VfkL8yQooZl5osI9cKMlSdogISu3QQnouq1EnG-eFoqDdaENI4groW3wwCoMrIK5mG97va_IaZ6IYeThvLAdxZSi9HY/s1600/Wall.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 259px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBBJzlrVxyas1a1reiyoYpSn7nYiSNrwPU0P90BJx8oyx-OJ-3VfkL8yQooZl5osI9cKMlSdogISu3QQnouq1EnG-eFoqDdaENI4groW3wwCoMrIK5mG97va_IaZ6IYeThvLAdxZSi9HY/s320/Wall.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5686214836254021874" /></a>Every year I enter a contest to see if I can create a game in seven days. It must be a roguelike game. Usually I write it in a language that I am comfortable in such as C++. I only tried writing my game in Java once. It was disappointing to say the least.<br /><br />I learned a lot of Java over the past over the last few months. I am ready to try my hand at a Java roguelike again. But first I thought I would practice with some roguelike library code. You know. I need to knock out some mundane stuff to be proficient for the real game design.<br /><br />Right now I am wrapping up the basics of maze drawing. I got some rooms connected by halls. Good stuff. The only problem is that the user can navigate around the maze. When I get too close ot the side of the maze, I have some coding problems.<br /><br />The maze display is based on an array of BufferedString objects. I just index into them based on where the player is on the maze. I keep the player in the center of the screen. So when the player reaches the edge of the maze, we are faced with drawing cells that do not exist in the StringBuffer.<br /><br />Now an elegant solution would be to detect this and somehow append some virtual walls outside the edge of the maze. I might still opt for that grand solution. For now I am trying to hurry up and get stuff done. So I extend the edges of the maze in all directions to create an outside buffer. This ensures you can use the same dumb code to index into the BufferedStrings even when at the edge of the navigatable maze. Nice trick huh?Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-64067607176832826722011-12-14T13:05:00.004-05:002011-12-14T13:11:05.160-05:00The Outstanding Breakout<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoHhNA8Ip0MBuCm6Ij_eS52QDxcQjaNugyEDOQbRYwT0N68skwZ8vKr5cMLMpfemz6bEmz1FylTMBEv9IlrNuJP26j1zC67lROcQwiLDL-jUrvnQZKBFfSx92nRtGIcITGFhzqyBnl2pk/s1600/Breakout.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 214px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoHhNA8Ip0MBuCm6Ij_eS52QDxcQjaNugyEDOQbRYwT0N68skwZ8vKr5cMLMpfemz6bEmz1FylTMBEv9IlrNuJP26j1zC67lROcQwiLDL-jUrvnQZKBFfSx92nRtGIcITGFhzqyBnl2pk/s320/Breakout.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5686048176574149506" /></a>My advanced Java community college class did not have a final exam. Instead we needed to submit a final project. The instructor came up with a couple ideas for projects we could do. He also said he was open to other ideas upon his approvel.<br /><br />Initially I thought I might develop an electronic football game. Nothing like Madden. This would be a clone of the old Mattel hand held electronic football games from the 70's and 80's. Then I saw the idea of writing the arcade game Breakout and I knew I had to do it.<br /><br />The funny thing about the final is that most students opted to do the mortgage calculator. That has the advantage of being easy to do. The instructor provides the GUI and the equations to figure out mortgage payments. The student just needs to implement the equation and hook it up. Boring.<br /><br />The basic breakout game was pretty easy to implement. I had already coded some exercises with balls bouncing around the screen. I concentrated on my intro and game over screens. I alsmot used this game as a place for some demo graphics on those auxiliary screens. I also concentrated on game play. Another student was excited to play my game and give me UI feedback. In the end I spent a lot of time developing this game. My instructor called is amazing and outstanding.<br /><br />The real win from this game is the stuff I learned from doing it. It is now a part of my JAva portfolio. Yeah I could have done the mortgage calculator. But where's the glory in taking the easy way out and cheating myself?Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0tag:blogger.com,1999:blog-174910063051315281.post-61136532428036670022011-12-13T13:03:00.003-05:002011-12-13T13:07:30.351-05:00Maze Design<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgruxdIO7z83vuZOl0LKfl97Mx3XyE2JRGE15kpj3TjkVvlSHEZCPKE71RGtnI-6jIQSWcvwMXoFEQdwu_QAbw3vHNkpfKifloS8q8EL866I37LplqhtAu1CO6bMwTVo_5heXzKXGlkto/s1600/Design.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 308px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgruxdIO7z83vuZOl0LKfl97Mx3XyE2JRGE15kpj3TjkVvlSHEZCPKE71RGtnI-6jIQSWcvwMXoFEQdwu_QAbw3vHNkpfKifloS8q8EL866I37LplqhtAu1CO6bMwTVo_5heXzKXGlkto/s320/Design.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5685675342869599570" /></a>I am struggling on how to internally represent my roguelike maze. Currently I maintain a 2D array as well as an array of StringBuffers. The array is used for easy lookup of objects in the maze. The StringBuffer is used to quickly generate a string to draw on the screen. The problem is that I need to update both structure every time something moves in the maze.<br /><br />I could just keep the 2D array. Then I could generate the Strings on the fly as I need to display. However I do a lot of display updates (whenever the player moves). That might take a lot of time to generate an 80x25 worth of character Strings.<br /><br />Or I could just keep everything in the String array. Then I could index into it when I need to check different cells of the maze. That just does not feel as natural as the separate 2D array though.Mister Bahhttp://www.blogger.com/profile/11735506939987403506noreply@blogger.com0