Monday, January 4, 2016

ODTUG APEX Gaming Competition - How'd They Do It? (Part 10)

At Kscope 15 this year we launched the first ever ODTUG APEX game competition. The APEX community responded with 15 entries! Each and every one of them left me thinking "How'd they do that?" So, let's find out more about the games and those who wrote them.

Our third place entry comes from Matt Mulvaney.

First off, tell me a little about yourself.
I’m Matt Mulvaney, a Senior Consultant who works at Explorer UK. 
You can follow me on Twitter @matt_mulvaney
How many years of APEX experience do you have?
Since version 4.1
What motivated you to participate in the APEX Gaming Competition?
It's a funny story. I had this computer game when I was a kid, I thought it was called Rescue42 or Rescue, something similar – I even forgot what it was called. 
Well I was reunited with it again earlier this year after about 267 google searches over many years. I discovered it was available for the Spectrum (even though I’ve never owned a Spectrum – yes I have no clue how I even managed to play it) and it emulated well. 
When I started to play it, I immediately remembered how you had to read and hold a load of information in your head before you even started the game and how some of the levels where really annoying and uncontrollable. I actually found some magazine scans of this game from the 80’s and after reading through those it appears as though this game is mediocre at best and it was a largely forgettable title. 
Does this even matter to me? Hell no! This was my childhood game and I loved it.

Fast forward a few months and I read about the ODTUG gaming competition and this game was just ripe for a make-over APEX style.
What is the name of your game?

The game is called Rescue42 which is what I thought the original game was called. 
I thought it might have been rescue42.exe or rescue42.bas (yup, Basic) but I wasn’t sure. The original game was actually just called Rescue (or sometimes Resqué - due to a misprint). 
Since there are 41 locations with the Castle as the 42nd location the new name kind of makes sense.

Briefly describe your game.
The game's plot is a pretty old school video gaming one – you have to rescue the princess from the castle and then return her to the safety of your base. 
The game is spread over two levels. The first level you have to dodge the guards and find items which leads to the discovery of the castle. Once you find the castle, in level two, you have to play a series of mini-games before you find the princess and then return her to your base. Simple. 
The original game had about 12 pages of text to read – my version has a minimized Guided Tour.
How long did it take you to develop your games?
Because a couple of decades had passed since I last played it, I had to re-learn the entire game again through an emulator (I'm so grateful for save states) so a few hours were spent scribbling down notes on the game. 
I started this game on my lunch hour and when the deadline approached I also worked on it during the evening in front of TV shows like The Apprentice and Better Call Saul. 
I didn’t track my time but I do remember a painful hour spent typing in coordinate data.
What was the most challenging element of your game design and how did you overcome it?
I realized early on that the game had to work with dynamic actions rather than page submissions as it had to run quick and feel like a game. However due to the large amount of dynamic actions required, a problem I found was that the game's performance ran like light speed on my laptop but ran like potatoes on apex.oracle.com. 
This ran especially slow on the Reversi mini-game. I included a single player Reversi mini-game because I really like the game but oh-my-days was the mathematics & AI difficult to implement. 
The whole AI is written as a single SQL statement (isn’t that neat?) and is based on my style of play. The AI kept beating me so it was really difficult to write the ‘hey you’ve won’ screen – because, you know, that didn’t happen very often... how dare my creation beat me at my own game! 

Back to the main game, the nail-biting stuff was when I got a large component to work, for example the Guard Movements, I had to deconstruct it and remodel it so that it also worked when the player moved, looked, picked, etc. I also kept to my rule that I didn’t want to include any server side tables, objects, etc. – I wanted this to be totally APEX based. Without server-side code I therefore had a lot of dynamic actions which I needed to run over and over again - like a module, which isn't available in APEX. I achieved this by representing these as hidden items which included a select dynamic action and ran them on demand using apex.event.trigger. 
Monty, you wanted me to get technical; so you can read more on this approach here. 
Another grueling issue I had was transferring the player score when you are returning the princess back to your base when you beat the game – it would not work and it occurred just before the deadline too. I tried everything, the score would not set in session. In the end I used some of the techniques in this blog to force the score to session.

The artwork is inspired from the original cassette inlay and I used a silhouette theme throughout to keep it consistent. 
By the way, I really like some of the images in Level 2... if you make it that far.
Alright, how can I play?
Adrian Png is hosting the game for me. You can play it at http://bit.ly/Rescue42 
Anything else you'd like to add?
Hope you enjoyed reading and you enjoy playing the game – to read more about this game click the link above and then click 'About this Game'. I won 3rd place in this competition so thank you to ODTUG for my membership and the Chromecast.

If anyone is reading this and hasn't used APEX yet, I encourage you to get started. Its a fantastic tool with a superb community which organises great competitions such as this one.


Thanks, Matt. There's no school like old school!! Great work!




...our journey continues



Thursday, December 31, 2015

I Beg Your Pardon

In June of 2012, my first action as President of ODTUG was to relieve Edward Roske of any and all duties related to Conference Chairman.


It seems fitting that my last act as ODTUG President is to issue the full and complete Presidential pardon Edward has sought these many years.



Therefore, ...


By the President of ODTUG a Proclamation
Edward Roske became the KScope Conference Chairman on July 1, 2010 and was reelected in 2011 for a second term by the ODTUG Board of Directors. His term in office continued until his dismissal on June 25, 2012.
Edward Roske was found to be guilty of increasing the popularity, prestige, and profitability of the 2011 and 2012  KScope Conferences without prior consent of the ODTUG President and Board of Directors.  
Now, THEREFORE, I, MONTY L. LATIOLAIS, President of ODTUG, pursuant to the pardon power conferred upon me, have granted and by these presents do grant a full, free, and absolute pardon unto Edward Roske for all offenses against ODTUG and the KScope Conference which he, Edward Roske, has committed or may have committed or taken part in during the period from July 1, 2010 through June 25, 2012.
IN WITNESS WHEREOF, I have hereunto set my hand this thirty-first day of December, in the year of our Lord two thousand and fifteen.
MONTY L. LATIOLAIS


... our journey continues


Wednesday, December 23, 2015

ODTUG APEX Gaming Competition - How'd They Do It? (Part 9)

At Kscope 15 this year we launched the first ever ODTUG APEX game competition. The APEX community responded with 15 entries! Each and every one of them left me thinking "How'd they do that?" So, let's find out more about the games and those who wrote them.

Our winning entry comes from Anderson Rodrigues Ferreira.

First off, tell me a little about yourself.
My name is Anderson Rodrigues Ferreira.
I am from Brasilia, the capitol of Brazil! I am a Computer Engineer at Brazilian Court of Audit (Tribunal de Contas da União - TCU). 
I am Oracle Apex Developer Expert Certified; Oracle Database SQL Expert Certified and Professional Scrum Master Certified. 
I am Apex speaker in Latin American events. 
I am the coordinator of the Apex Tour Latinoamérica, the greatest Apex-only event of Latin America. 
If you want to reach me.
My twitter: @andersonrf81 
My blog: andersonapex.blogspot.com.br (Only in Portuguese! Sorry!)
How many years of APEX experience do you have?
6 years of Apex experience. I started in Apex 3.2
What motivated you to participate in the APEX Gaming Competition?
I love Apex, so developing a game in Apex would be great!
I like challenges and as we are upgrading Apex to version 5, I wanted experience in Apex 5. 
We decided enter the competition seven days before the submission limit, when we noticed that they changed the submission date.
This game is my first Apex 5 application! 
What is the name of your game?

The name of the game is APEX Hold'em Truco.

Briefly describe your game.
It is a multiplayer game based on Truco, the most played card game in Brazil. If you want to play alone, robots will play against you. 
This game is for four players in fixed partnerships, partners sitting opposite. 
A game consists of a series of rounds, in each of which a partnership may win one or more points. The first partnership to collect 12 (or more) points over many rounds wins the game.
How long did it take you to develop your games?
It took me 7 days! This shows us how quickly we can develop in Apex 5!
What was the most challenging element of your game design and how did you overcome it?
The discard in a multiplayer game. To solve the problem, we used a Dynamic Action that submits the discharged card and saves the cards in a table and every player refreshes periodically the page to get the cards in the game.
Alright, how can I play?
The game can be reached in the following link:
You only need to create a player (name and avatar) and select/create a game table!

Anything else you'd like to add?
Our game is a 100% Apex application and it was developed in only 7 days. It works on desktop or mobile devices. 
I loved this competition and I am planning on participate next year again!
I'd like to add that I learned a lot of Apex painting a bathroom with Monty in Kscope!


Thanks, Anderson. I remember that day well. ODTUG KScope12 Community Service Day in San Antonio.

In fact, I was able to scare up a picture or two.
We were so young...so innocent.

It was a pleasure working beside you that day and I'm happy to call you my friend.




...our journey continues




Tuesday, December 22, 2015

A Case for Reference Models

I've used the SQL Model Clause on occasion. I've spoken on the topic as recently as last Friday to our internal development staff. I tried to stress to them that it's something that belongs in the toolbox, but it's not a tool you will pick up frequently.

One of the topics mentioned during the preso was REFERENCE MODELS. While I was aware of reference models, I never had the need to employ them.  I have no real world experience utilizing them.

Afterwards, Martin D'Souza asked for an example using REFERENCE MODELS. I was more than a little suspicious. I figured he had a requirement somewhere that he thought could best be implemented using a model clause and REFERENCE MODELS. I was right to be suspicious.

What he asked for was multiple Top-N queries within the same result set. Put another way, using the EMP table, in col A he wants the 5 highest salaries, while in col B he wants the 5 oldest dates of hire. THERE IS NO CORRELATION BETWEEN COLUMNS.

Using the MODEL clause and two REFERENCE MODELS, we were able to give him precisely what he was looking for.


select top_salary,
       recent_dates 
from dual
model 
reference t_salary on (
   select rn,sal 
     from (select ROW_NUMBER() OVER (ORDER BY sal DESC) rn,
                  sal 
             from scott.emp) 
    where rownum <=5)
   dimension by (rn)
   measures (sal)
reference t_dates on (
   select rn,hiredate 
     from (select ROW_NUMBER() OVER (ORDER BY hiredate) rn,
                  hiredate 
             from scott.emp)
    where rownum <=5)
   dimension by(rn)
   measures (hiredate)
main t_main
   dimension by (rownum as x)
   measures (0 as top_salary, SYSDATE as recent_dates)
   rules iterate (5) (
     top_salary[iteration_number+1]   = t_salary.sal[iteration_number+1],
     recent_dates[iteration_number+1] = t_dates.hiredate[iteration_number+1]
     )


I'm sure there are other ways to satisfy Martin's requirement - there always are.

The reason I wanted to share this is that my perception of REFERENCE MODELS has changed. Whereas before, I figured REFERENCE MODELS would best be used to access supplemental or complementary information to the main model. I expect they could also improve readability. I now understand that REFERENCE MODELS can be used to pull together information that is completely non-correlated.....in our case associated only by row number.

Thanks, Martin. You made me look at things differently.


...our journey continues.

Monday, December 21, 2015

ODTUG APEX Gaming Competition - How'd They Do It? (Part 8)

At Kscope 15 this year we launched the first ever ODTUG APEX game competition. The APEX community responded with 15 entries! Each and every one of them left me thinking "How'd they do that?" So, let's find out more about the games and those who wrote them.

Marcelo Burgos...would you please stand and address the class?.


First off, tell me a little about yourself.

My name is Marcelo Burgos, co-founder of Argentina Oracle Users Group and the Apex Tour Conference. Also I work for the Universidad de Buenos Aires and I'm a self-employed Apex developer.
How many years of APEX experience do you have?
I've more than 8 years working with Apex.

What motivated you to participate in the APEX Gaming Competition?
My wife is a Math teacher and asked me for a solution for get their students put a little enthusiasm in the classroom. I thought I could kill two birds of one shot, developing a game for help the students to study geometry with fun, and if possible, for winning the Apex gaming competition.
What is the name of your game?

The name of the game is Leonhard, which is a tribute to Leonhard Euler, the Graphs theory father.

Briefly describe your game.
The game consists of multiple graphics, and you have to "draw" over all the lines of each figure without "lifting the pencil from the paper". You cannot pass the "pencil" twice for the same line. 
For draw a line you have to click at both ends.
How long did it take you to develop your games?
I  developed the app in five stages. Each stage took us a week for thinking and a couple days for coding. The game have a lot of artwork that took other two days to transform from analog (paper) to digital (database).
What was the most challenging element of your game design and how did you overcome it?
Technically, the app works drawing lines and points over a html5 canvas element.

An Ajax callback pl/sql process works dynamically building javascript code each time you clic a point. We had to resort to a lot of Oracle techniques such as functions and Apex collections, and we had to resort a special canvas library for facilitate the identification of the points you clic during the game.
Alright, how can I play?
You can play the game at the url https://apex.oracle.com/pls/apex/f?p=31416 and uses open authentication although is mandatory to enter your name.
Anything else you'd like to add?
After the competition we follow working in the program due is expected to be used for my wife's students. After removing a couple bugs, now we get to include 3D shapes in the game, and now also we translated the app to spanish. That sounds simple, but we had to work a lot to fix an unexpected problem: numeric format after language localization brokes all the code inside the javascript.  
You learn something new every day.


Thanks, Marcelo. In the coming days we'll share more insight into a few of the remaining games that were part of the contest.

...our journey continues

Wednesday, December 16, 2015

ODTUG APEX Gaming Competition - How'd They Do It? (Part 7)

At Kscope 15 this year we launched the first ever ODTUG APEX game competition. The APEX community responded with 15 entries! Each and every one of them left me thinking "How'd they do that?" So, let's find out more about the games and those who wrote them.

Next up is the one...the only....Nick Buytaert.


First off, tell me a little about yourself.

My name is Nick Buytaert and I work as an Oracle consultant for Contribute NV. We are located in Belgium. You can always contact me on Twitter @nbuytaert1 or through my blog APEXPLAINED at https://apexplained.wordpress.com/.


How many years of APEX experience do you have?

I have around five years of Oracle APEX experience.

What motivated you to participate in the APEX Gaming Competition?
The APEX Gaming Competition was a great opportunity to step outside APEX its comfort zone. Instead of working on a back-office business application, I had the chance to develop an actual game. 


What is the name of your game?
The name of the game is MoviePick.



Briefly describe your game.
MoviePick is a movie guessing game based on a movie database web API. 
The goal is to correctly guess five different movies by requesting specific hints. The more hints you need, the less points you will get per movie. There are four types of hints you can pick from: movie facts, actors, backdrops and character hints. 
After finishing the fifth round, you have the possibility to register your score.


How long did it take you to develop your games?
It took around two weeks to develop the game.


What was the most challenging element of your game design and how did you overcome it?
Before starting development, we had one important question to answer: “To invoke the movie database API from client or server side?”. The easy solution would have been to pick the client side. Calling a couple of web services in JavaScript (or jQuery) and storing their JSON result into a variable is pretty straightforward. However, this would mean that all movie information would just linger around in the browser. You would literally see the movie title passing by when keeping an eye on the incoming movie database AJAX responses. 
This idea bothered me too much and made me choose to invoke the movie database web services from server side. Each hint requested by the end user would then result in a separate AJAX call returning only the requested information.

Invoking the web services from PL/SQL also gave me the opportunity to play around with the new APEX_JSON package, which has been introduced in APEX 5.0. After getting familiar with the package, it was pretty easy to parse the movie database JSON responses and collect all relevant movie information.

Alright, how can I play?
You can play the game at http://contribute.be/moviepick/   No credentials required.

Anything else you'd like to add?
I'd like to thank ODTUG for the organization of the contest

Thanks, Nick. In the coming days we'll share more insight into a few of the remaining games that were part of the contest.

...our journey continues

Monday, December 14, 2015

ODTUG APEX Gaming Competition - How'd They Do It? (Part 6)

At Kscope 15 this year we launched the first ever ODTUG APEX game competition. The APEX community responded with 15 entries! Each and every one of them left me thinking "How'd they do that?" So, let's find out more about the games and those who wrote them.

Let's go down under and talk with Scott Wesley.


First off, tell me a little about yourself.

My name is Scott Wesley and I'm a consultant for Sage Computing Services in Perth, Australia. You can tweet me @swesley_perth and read my blog at grassroots-oracle.com


How many years of APEX experience do you have?
I started learning 3.2 in 2008, so 7. I guess this now eclipses how long I spent on Oracle Forms.


What motivated you to participate in the APEX Gaming Competition?
I originally had no intention of submitting. I was in the middle of writing a book and travelling to Kscope then visiting the states for a month pushed me behind. 
When I returned to Australia I needed to continue writing but was lacking motivation.  I needed to get up to speed with APEX 5.0 and regain momentum, so when I thought of a game that I didn't think would take much to translate to APEX, so I went for it. 
But I bound myself to two major rules - it had to be as simple and declarative as possible.


What is the name of your game?
Boggex (Boggle + APEX)



Briefly describe your game.
Electronically roll 16 alphabet dice and find as many word combinations using the upturned letters as you can in two minutes. 
It's been reported that it can be quite addictive.


How long did it take you to develop your games?
After idea conception I gave myself a week to get it to a stable, working state. This meant nights, and whatever else I could sneak in. I gave it another once over just before the November submission date. Probably less than a working week. 
The productivity factor APEX 5 provides helped... ahem.


What was the most challenging element of your game design and how did you overcome it?
When using the page item and 'Try' button to submit words, the game was about 95% declarative. Mobile users needed to avoid the virtual keyboard, so I had to allow users to press on the board letters to simulate key presses. Enabling the game board for finger tap events made me think a little harder about jQuery selectors. 

Firslty I needed to tap on a letter, then respond by highlighting selected letter and add the letter to the word attempt. The highlight was just done by adding (or removing) a class called 'hover' which made the background of a letter on the game board a different colour. 
/* when hovering, or given hover class */
#p1_board td.t-Report-cell:hover
,#p1_board td.t-Report-cell.hover{
    background-color: #4992de !important;
}

I created an on click dynamic action on a jQuery selector that identified any cell on the game board. 
#p1_board td.t-Report-cell

Then added what turned out to be three lines of JavaScript action, using this.triggeringElement to refer to the cell that was clicked.
// if the cell hasn't already been clicked for this word
if (!$(this.triggeringElement).hasClass('hover')) {
  // add tapped letter to page item
  $s('P1_WORD', $v('P1_WORD') + $(this.triggeringElement).text());
  // sustain the hover style (see page attributes)
  $(this.triggeringElement).addClass('hover');
}

To replicate the highlight when typing the letter with the keyboard was fairly similar. I created a dynamic action Key release of my only visible page item P1_WORD, then added the following JavaScript 

// record the last value, for the tricky delete response
this.triggeringElement.oldvalue = this.triggeringElement.value;

// get value of page item, get last letter, set to upper case.
last_letter = $('#P1_WORD').val().substr($('#P1_WORD').val().length-1).toUpperCase();

// Add highlight to first unhighlighted button encountered with the same letter as that entered. Need to cater for Qu
if (last_letter.length > 0)
  $('#p1_board td.t-Report-cell:not(.hover):contains("'+last_letter+'"):first').addClass('hover');
// select reads: game board, any cell not already with hover class, cell must contain relevant letter

The hard part came when I realised I had to remove the relevant highlight if the user deleted the letter using the keyboard. The key release trigger ended up having a condition to run a set of false actions when the delete key was pressed:
event.which != 8

For iOS users, I also needed to include the TouchPunch.js library on the page. This fills a gap for desktop applications on touch devices. It also enables you to modify click events to respond immediately, instead of waiting 300ms to determine if you wished to click and drag, or just click. As such, this library is also required if you want to use sliders on a touch device.

What I never addressed was the one dice that had 'Qu', as per one of the inline comments.

Monty, you asked for detail, so I couldn't resist ;p

Alright, how can I play?
It's currently hosted on the apex.oracle.com server  https://apex.oracle.com/pls/apex/f?p=70316  
The login screen provides details of a generic user to play with, though in future I may just make the game page public.


Anything else you'd like to add?
Within my game you'll find a page of technical details, roughly describing how I used the SQL, PL/SQL, CSS and jQuery involved in building the game in APEX 5.0. 
I also presented a breakdown of technically interesting game components at the Perth OTN day.  Slides available here. 
I'm also tempted to record a brief video series showing how to construct it yourself. It's basically a single page application with a bunch of dynamic actions.

If you want to learn more about using jQuery in APEX, I finished writing a book this year on just that Click here for details   ;p


Thanks, Scott. By the way, it was great to meet you at KScope 15. In the coming days we'll share more insight into the other games that were part of the contest.

...our journey continues