Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Foone Turing committed Oct 26, 2017
0 parents commit e8bf30c
Show file tree
Hide file tree
Showing 7 changed files with 810 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
@@ -0,0 +1,26 @@
== Sierra Death Screen Generator

This creates GAME OVER/YOU DIED screens as seen in Sierra Online's SCI engine.
Right now, it only supports Police Quest 2

== Creating a new font ==

This is mainly a guide for me so I don't forget.

1. Extract the font file from the game using one of the SCI viewers, like SCI Companion or SCI Viewer
2. Run sci-font-extract.py to generate the font file + json file
3. Edit the json file to add the height/origin/box/null-character fields
4. Screenshot a game over in the game, crop the death screen, then edit out the text

== TODO ==

* Actually support games other than PQ2?
* Add a twitter-safe saving option, for death screens that aren't inherently twitter-safe
* Add options to adjust scaling.
* Let you change the titlebar text?
* Add custom backgrounds, not just the error box?

=== Other games to add ===
* Every SCI game
* AGI games?
* SimCity 2000 (YOU CAN'T CUT BACK ON FUNDING YOU WILL REGRET THIS!)
63 changes: 63 additions & 0 deletions index.html
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<title>Police Quest 2 Death Generator</title>
<style>
img.source{
display: none;
}
textarea{
font-family: monospace;
}
</style>
<script src="jquery-3.2.1.min.js"></script>
<img src="pq2-blank.png" id="template" class="source"/>
<img src="pq2-font.png" id="font" class="source"/>
<canvas id=death >No canvas!</canvas>
<p>
<textarea cols=40 rows=5 id=sourcetext>
Thank you for playing Police
Quest 2. Next time, be a little more
careful.
</textarea>
</p>
<script>
var scale = 2
var canvas = document.querySelector('canvas')
var context = canvas.getContext('2d')
var baseImage = document.querySelector('img#template')
var fontImage = document.querySelector('img#font')
var fontInfo=null

function renderText(){
var origin=fontInfo.origin
var bx=fontInfo.box.x,by=fontInfo.box.y
var text = document.querySelector("textarea#sourcetext").value.split('\n')
context.drawImage(baseImage, 0, 0, baseImage.width*scale, baseImage.height*scale)
var y=origin.y
for (let line of text){
var x=origin.x
for(var i=0;i<line.length;i++){
var info=fontInfo[line.charCodeAt(i)]
if(info==null){
info=fontInfo[fontInfo["null-character"]]
}
context.drawImage(fontImage,info.x,0,bx,by,x*scale,y*scale,bx*scale,by*scale)
x+=info.w
}
y+=fontInfo.height
}
}
$('#sourcetext').keyup(function(){
if(fontInfo != null){
renderText()
}
})
$(window).on('load', function(){
context.canvas.width = baseImage.width * scale
context.canvas.height = baseImage.height * scale
context.imageSmoothingEnabled = false;
$.getJSON("pq2.json",function(data){
fontInfo = data
renderText()
})
});
</script>
4 changes: 4 additions & 0 deletions jquery-3.2.1.min.js

Large diffs are not rendered by default.

Binary file added pq2-blank.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pq2-font.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e8bf30c

Please sign in to comment.