Home | TroyDPatterson.com

Got a new package.

March 31st, 2010

In the end… all of this does link together towards one major project I am working on. But, in the mean time I have to catch up on my reading. :)

Nick Valentino's Thomas Riley

Read the rest of this entry »

Keyboard LEDs

March 26th, 2010

While I was trying to figure something else out code wise , my mind began to wander. I started thinking about a cheap man’s pinball machine. Now this has been an off again on again project of mine for the past few months. But yesterday I thought about how many 3.5 SBCs that I have and what I could do with them. Originally I wanted to take one throw it inside of a desktop pinball machine and have some crazy serial connections going back and forth to control everything. I then found that the SBCs are over kill.

So, yesterday the idea popped in my head again, but more for haha sake, I wanted to see if I could make the LEDS on a keyboard flash using C#. And in doing this I could use the current that would come from the LEDS to power a relay and turn on the Solenoids/Flippers. Just a concept. Nothing really extreme or solid, just a simple proof of concept(I’ve been in to those a lot recently.)

So I coded it out as a Console Window application using 1 C# file and the command line to compile it. (That way I couldn’t lazy my way out and use help files.) Here’s what I have.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace popsknot.griz.keyFlasher
{
public class keyFlasher
{

[DllImport("user32.dll")]
static extern ushort GetKeyState(short nVirtKey);

[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);

public const ushort keyDownBit = 0x80;

const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;

private static int counter = 10;
private static bool rFlipper = false;
private static bool lFlipper = false;

public static void Main(string[] args)
{
if (Control.IsKeyLocked(Keys.Scroll))
{
keybd_event(0x91, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0x91, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

}

if (Control.IsKeyLocked(Keys.NumLock))
{
keybd_event(0x90, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0x90, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

}

while (counter !=0)
{
if (IsKeyPressed(Keys.Escape))
{
counter = 0;
}

//Right Flipper
if ((System.Windows.Forms.Control.ModifierKeys & Keys.Control) == Keys.Control)
{
if (!rFlipper)
{
Console.WriteLine("Trigger Right Flipper" + 0x90);
keybd_event(0x91, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0x91, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
rFlipper = true;
}
}
else
{
if (rFlipper == true)
{
keybd_event(0x91,0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0x91, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
rFlipper = false;
}
}

//Left Flipper

if ((System.Windows.Forms.Control.ModifierKeys & Keys.Alt) == Keys.Alt)
{
if (!lFlipper)
{
Console.WriteLine("Trigger Left Flipper" + 0x90);
keybd_event(0x90, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0x90, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
lFlipper = true;
}
}
else
{
if (lFlipper == true)
{
keybd_event(0x90, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0x90, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
lFlipper = false;
}
}
}
}

public static bool IsKeyPressed(Keys key)
{
return ((GetKeyState((short)key) & keyDownBit) == keyDownBit);
}
}
}

Also keep in mind that I did about 2 minutes of testing on this on my development machine. That means that there is a chance I may be doing something wrong and it could cause damage to something. So, use at your own risk.

Another day another project

March 26th, 2010

So here I am, I’ve been looking at what I worked on in 2009 and it’s lack of appearances in the toybox. And keep asking myself, “why do I keep neglecting the toybox?”The answer to that is still. I don’t know. I have two things from 2010 that I just… Ah well I’ll talk about them some other time.

First video test

March 14th, 2010

Ok… I know that it’s quiet and all. I couldn’t think of anything clever to say. I’ve uploaded video of the networking demo I’ve been working on for the past few weeks. Yes, it’s a remake of the Combat game I was working on a few years ago. This time I’m trying to make it network based.

It’s very difficult to show networking on two laptops when your physical space is limited by a small cluttered apartment. So I’m quite proud of myself and my first real time networking application.
Another thing you may notice is that the player jumps and pops in to place. This is myself trying to pick up where networking lag some times happens. It’s amazing how fast things tend to be off in something that requires fast button pushing. I’m going to have to stop right here with this project because I’m not sure if the real-time speed required of a tank game is going to work.

I think my next Actionscript 3 and Networking project will be something turn based or slower placed. I’m still trying to refine my skills to make a decent speed application.

Whoooo it’s doing something right!

March 7th, 2010

Combat image 1
I’ve gotten it to recognize all of the players whenever someone logs in!

Next step “Display”…

March 7th, 2010

So I have the network going(for this combat game), where it’s sending the information between all different players, now I’m going to reinstate the rendering engine. Since I come from a different way of thinking, I’ve been fighting against Actionscript 3 a majority of the road. Even though I’m trying to incorporate the previous rendering engine in a different way, I feel like this is either cheating or the incorrect way to do things. After I finish this project I’m going to have to pick up a real game programming in Actionscript 3 book.

I need that physical thing in hand. eBooks and forums aren’t working for me.

Actionscripting 3 – Day… I don’t know

March 2nd, 2010

A last year I created games that I solely developed while on the train going to and from work. I should say I started to develop, because I could only work on it when I had the time. Since then my workload exploded in to a mess of content management systems and repair work for other studios. That left me with little time on the train to think about side and personal projects. And then my office moved, shortening my commute to the point where I didn’t have time to even open my laptop (let alone have space on the more crowded train) to continue my same development methods…
Read the rest of this entry »