## Nixon Newton Digital simulator v0.1

slydc
Prole
Posts: 11
Joined: Mon Jul 09, 2012 12:37 pm
Contact:

### Nixon Newton Digital simulator v0.1

Hi again folks!

Since that my first simulator (Marx TV Tennis) doesn't interest people, i've done another simulator.
The program simulate the Nixon Newton Digital watch (model A137-100) with all it's functions, and
the best ting is that you don't have to set the time or date (reads it off from your computer).

For now, it's mostly a screensaver-type. If you want to know all the buttons, just press "F9" to
know everything. Also this watch has a hidden Pong game but it's not done yet (will be done in the
next version). But you can press "F12" to show a (preview) screenshot of the game.

I also put a hidden feature (F4), which blanks the first digit (the upper-left) since the watch doesn't
display the "zero" before 10 o'clock but i'm still trying to figure out how to blank the first digit auto-
matically (seems the LUA string to print the hours can't be modified...sigh).

And finally, hope i won't get any trouble with Nixon by simulating their watch.
0preview.png (73.18 KiB) Viewed 3821 times
Nixon (v0.1-1).love
Nixon (v0.1).love
Last edited by slydc on Mon Nov 26, 2012 11:56 pm, edited 1 time in total.
--- Sly DC ---
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

### Re: Nixon Newton Digital simulator v0.1

That is so cool!

Were you trying to add a space to the start of the hour string, and it wouldn't work? If so, I think that's because there's no space character in the imagefont. If you added a blank rectangle to the end of the imagefont image, and added the space to the string of characters given to newImageFont, it should work. Then you could simply do this:

Code: Select all

local hour = tonumber(os.date("%I"))
if hour < 10 then hour = ' ' .. hour end
love.graphics.print(hour,287,174)
slydc
Prole
Posts: 11
Joined: Mon Jul 09, 2012 12:37 pm
Contact:

### Re: Nixon Newton Digital simulator v0.1

Hi Santos,

Thanks very much for the comment and especially about how to put a blank space. It works like a charm!
Again, thanks very much!

With your solution, i also added an extra feature: to change color display. You can either have the original (LCD black & grey),
inverted, red, green, blue, orange or violet. Now i only have to do the hidden game and the simulator should be final (hoping
there won't be any kind of problem(s)).

--- Sly DC ---
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

### Re: Nixon Newton Digital simulator v0.1

Nice!

Just to note, math.randomseed(os.time()) is actually called automatically by LÖVE in the default love.run function.

Also, another way to align the hour number would be with love.graphics.printf. The 4th argument is the reference width the text is aligning to (or the "box" it's in), and the 5th is the align mode. So you could do something like this...

Code: Select all

local hour = tonumber(os.date("%I"))
love.graphics.printf(hour, 287, 174, 242, 'right')
The reason for 242 instead of 240 I think is because ImageFonts have 1 pixel letter spacing.

Another way to change the colour of the digits could be to use love.graphics.setColor to tint the image. If you used an image with white text and a transparent background, like this...
digits.png (504 Bytes) Viewed 3728 times
... you could then call love.graphics.setColor before drawing it with the colour you want it to be.

And you could store the colours in a table...

Code: Select all

colors = {
{255, 0, 0},    -- red
{65, 160, 43}  -- green
--etc.
}
... and then have a number which indexes the table which increments when you press F4...

Code: Select all

if key == "f4" then
selectdigits = selectdigits + 1
if selectdigits > #colors then selectdigits = 1 end
end
... and you could set the font in love.load...

Code: Select all

digits = love.graphics.newImageFont("data/digits.png", "1234567890 :")
love.graphics.setFont(digits)
... and then love.draw could look something like this!

Code: Select all

function love.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.draw(backgrnd0, 0, 0)
love.graphics.setColor(colors[selectdigits])
local hour = tonumber(os.date("%I"))
-- etc.
end
And you could do the same thing with the background if you wanted to, or even the watch maybe!
slydc
Prole
Posts: 11
Joined: Mon Jul 09, 2012 12:37 pm
Contact:

### Re: Nixon Newton Digital simulator v0.1

Hi again Santos,

And again, thanks for all those solutions, this is great. I tried to change the codes with all your suggestions but seems
that digit.png doesn't like at all the codes. When i pressed "F6", here's what is shows:
GLITCH.png (106.59 KiB) Viewed 3719 times
So the font is overlaping onto another (the digits looks like alien...LOL!), your idea of using a transparent font
is great and that it will shave off some codes but especially very less PNG images to load, but seems that the program
doesn't like it at all... (same for different colors when pressing "F4", they show the same glitch)

Now i don't know what to do to correct this except if i use the old codes (not the best, but it works).
--- Sly DC ---
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact: