I was looking for a way to make my resume stand out more and somewhere down the line I started thinking about what PDFs can do. I learned that PDFs do support Javascript -- though not a lot of people use it. I thought it would be cool to try build a simple game that runs inside a PDF so here it is.
Snake running in a PDF (last page.) Works on Firefox and Adobe Reader (desktop). But it won't work in Chrome and Edge.
Technical details:
(1) I used a 2d grid of input fields resized as cubes to provide a 'pixel'-like screen.
(2) Each input has a coordinate and the game code manipulates the background color of the inputs to provide a 'display.'
(3) To support input for the game there is a hidden input field tied to keypress events. The event handler listens for keys to move the snake and ignores the rest. Starting the game automatically 'clicks' this hidden input.
(4) Finally, there is an interval timer that runs every N ms to update the screen and game state. E.g. as the snake moves in one direction the game loop runs and 'draws' onto the screen. It is responsible for collisions, food, and so on.
That's about it. I think there's a lot of potential to be creative with PDFs. I know snake is only basic but I thought it was cool anyway.
just looks like broken foolish to anyone with a decent setup (i.e. not using Adobe). and most enterprises with a minimally capable IT will not be running js in Adobe reader either.
Snake running in a PDF (last page.) Works on Firefox and Adobe Reader (desktop). But it won't work in Chrome and Edge.
Technical details:
(1) I used a 2d grid of input fields resized as cubes to provide a 'pixel'-like screen. (2) Each input has a coordinate and the game code manipulates the background color of the inputs to provide a 'display.' (3) To support input for the game there is a hidden input field tied to keypress events. The event handler listens for keys to move the snake and ignores the rest. Starting the game automatically 'clicks' this hidden input. (4) Finally, there is an interval timer that runs every N ms to update the screen and game state. E.g. as the snake moves in one direction the game loop runs and 'draws' onto the screen. It is responsible for collisions, food, and so on.
That's about it. I think there's a lot of potential to be creative with PDFs. I know snake is only basic but I thought it was cool anyway.