Final Project Final Post
Whoops, forgot to get this up by 10am today.
Annnnnnywho, last project, nicknamed Death Buttons by Prof. Jacobs, is an 8 button control pad which uses serial byte transmission to differentiate between the 8 different buttons. I had a few ideas for games to integrate the 8 buttons and their orientation on the game pad. The buttons are arranged in two columns to allow for two-player use without being cramped, as I was initially hoping to create a head to head game. One game idea was a sort of soccer-pong with 4 goals on each player's side, and the buttons would be used to move the goalies to a corresponding goal to defend/shoot a new ball. However, time constraints along with being way out of practice with Director eliminated the game from the equation.
The controller sends ASCII symbols as bytes for each button. Player 1 has buttons which send A through D, and player 2 gets lower case a-d. In this respect, the controller works properly, and gives discrete and distinguishable input to the CPU. Here's my code.
Public Const LeftA as Byte = 15
Public Const LeftB as Byte = 16
Public Const LeftC as Byte = 17
Public Const LeftD as Byte = 18
Public Const RightA as Byte = 10
Public Const RightB as Byte = 9
Public Const RightC as Byte = 8
Public Const RightD as Byte = 7
Option Explicit
Public Sub Main()
Dim button as byte
Dim outQ(1 to 40) as byte
Dim inQ(1 to 10) as byte
Dim outString as string
Dim state as boolean
Dim bNum as byte
call openqueue(inQ, 10)
call openqueue(outQ, 40)
call definecom3(11, 12, bx1000_1000)
call opencom(3, 9600, inQ, outQ)
do
for button =7 to 10
state = getpinvalue(button)
if state = true then
if(button = 7) then
'outstring = "Right D"
bNum = 100
call putqueue(outQ, bNum, 1)
end if
if(button = 8) then
'outstring = "Right C"
bNum = 99
call putqueue(outQ, bNum, 1)
end if
if(button = 9) then
'outstring = "Right B"
bNum = 98
call putqueue(outQ, bNum, 1)
end if
if(button = 10) then
'outstring = "Right A"
bNum = 97
call putqueue(outQ, bNum, 1)
end if
end if
next
for button =15 to 18
state = getpininvvalue(button)
if state = true then
if(button = 15) then
'outstring = "Left A"
bNum = 65
call putqueue(outQ, bNum, 1)
end if
if(button = 16) then
'outstring = "Left B"
bNum = 66
call putqueue(outQ, bNum, 1)
end if
if(button = 17) then
'outstring = "Left C"
bNum = 67
call putqueue(outQ, bNum, 1)
end if
if(button = 18) then
'outstring = "Left D"
bNum = 68
call putqueue(outQ, bNum, 1)
end if
end if
next
' delay 0.1
loop
End Sub
Public Function GetPinValue(ByVal button as Byte) as Boolean
if(GetPin(button)=0) Then
getpinvalue = false
else
getpinvalue = true
end if
end function
Public Function GetPinInvValue(ByVal button as Byte) as Boolean
if(GetPin(button)=1) Then
getpininvvalue = false
else
getpininvvalue = true
end if
At first I attempted to send the data as strings, but quickly switched back to bytes for the sake of simplicity and achieving function. The two functions define the 'pressed' state for each player. I did not realize until I got home that I had purchased a 4 pack of naturally-open buttons and one pack of naturally-closed. Breaking my code into two parts with inverted check functions quickly solved this and stopped player 2 from sending all 4 buttons all the time.
The device is housed in a project box from radio shack and has an integrated serial cable design. Power is supplied from the wall adapter and a mounted power jack on the box itself. Pictures will be up once they are uploaded to mycourses.
Whoops, forgot to get this up by 10am today.
Annnnnnywho, last project, nicknamed Death Buttons by Prof. Jacobs, is an 8 button control pad which uses serial byte transmission to differentiate between the 8 different buttons. I had a few ideas for games to integrate the 8 buttons and their orientation on the game pad. The buttons are arranged in two columns to allow for two-player use without being cramped, as I was initially hoping to create a head to head game. One game idea was a sort of soccer-pong with 4 goals on each player's side, and the buttons would be used to move the goalies to a corresponding goal to defend/shoot a new ball. However, time constraints along with being way out of practice with Director eliminated the game from the equation.
The controller sends ASCII symbols as bytes for each button. Player 1 has buttons which send A through D, and player 2 gets lower case a-d. In this respect, the controller works properly, and gives discrete and distinguishable input to the CPU. Here's my code.
Public Const LeftA as Byte = 15
Public Const LeftB as Byte = 16
Public Const LeftC as Byte = 17
Public Const LeftD as Byte = 18
Public Const RightA as Byte = 10
Public Const RightB as Byte = 9
Public Const RightC as Byte = 8
Public Const RightD as Byte = 7
Option Explicit
Public Sub Main()
Dim button as byte
Dim outQ(1 to 40) as byte
Dim inQ(1 to 10) as byte
Dim outString as string
Dim state as boolean
Dim bNum as byte
call openqueue(inQ, 10)
call openqueue(outQ, 40)
call definecom3(11, 12, bx1000_1000)
call opencom(3, 9600, inQ, outQ)
do
for button =7 to 10
state = getpinvalue(button)
if state = true then
if(button = 7) then
'outstring = "Right D"
bNum = 100
call putqueue(outQ, bNum, 1)
end if
if(button = 8) then
'outstring = "Right C"
bNum = 99
call putqueue(outQ, bNum, 1)
end if
if(button = 9) then
'outstring = "Right B"
bNum = 98
call putqueue(outQ, bNum, 1)
end if
if(button = 10) then
'outstring = "Right A"
bNum = 97
call putqueue(outQ, bNum, 1)
end if
end if
next
for button =15 to 18
state = getpininvvalue(button)
if state = true then
if(button = 15) then
'outstring = "Left A"
bNum = 65
call putqueue(outQ, bNum, 1)
end if
if(button = 16) then
'outstring = "Left B"
bNum = 66
call putqueue(outQ, bNum, 1)
end if
if(button = 17) then
'outstring = "Left C"
bNum = 67
call putqueue(outQ, bNum, 1)
end if
if(button = 18) then
'outstring = "Left D"
bNum = 68
call putqueue(outQ, bNum, 1)
end if
end if
next
' delay 0.1
loop
End Sub
Public Function GetPinValue(ByVal button as Byte) as Boolean
if(GetPin(button)=0) Then
getpinvalue = false
else
getpinvalue = true
end if
end function
Public Function GetPinInvValue(ByVal button as Byte) as Boolean
if(GetPin(button)=1) Then
getpininvvalue = false
else
getpininvvalue = true
end if
At first I attempted to send the data as strings, but quickly switched back to bytes for the sake of simplicity and achieving function. The two functions define the 'pressed' state for each player. I did not realize until I got home that I had purchased a 4 pack of naturally-open buttons and one pack of naturally-closed. Breaking my code into two parts with inverted check functions quickly solved this and stopped player 2 from sending all 4 buttons all the time.
The device is housed in a project box from radio shack and has an integrated serial cable design. Power is supplied from the wall adapter and a mounted power jack on the box itself. Pictures will be up once they are uploaded to mycourses.

