Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. Thank you for your support. Tom Speirs

Patreon

Simple "Simon Says" code for LED controler?


RIP-Felix

Recommended Posts

Has anyone rigged up a simon says game for their RGB LED arcade buttons using an LED controller (Arduino, PACLED64, whatever)? I'm looking into adding RGB LEDs buttons to my X-arcade Tankstick. I'm looking for other uses/games that could take advantage of them. I like the old simon says game and think it would be cool if that could be launched with GameEX. The screen would not even be needed, but could integrated somehow. I kind of wish I was better at programing. This gives me some neat Ideas.

Wondering if anyone has heard of this somewhere. Maybe you can point me to some code.

Link to comment
Share on other sites

If i'm understanding correctly you want to integrate this with this? ^_^

It probably can be done yes, but would take some work, and to integrate into GameEx would take even more amounts of effort as you'd need to make a program/software first.

You could probably connect the Simon Says PCB to your arcade buttons quite easily though.

Link to comment
Share on other sites

I found a JavaScript source for a simple HTML based mockup of the game here. The number of buttons is correct but I would need to know code to figure out how to map these to the button switches and LED controller. Perhaps I could rework the simple visual display to reflect the buttons and their colors to match my CP, then it would display correctly on the monitor. Of course this being HTML I would have to imbed it in a webpage (I assume). I don't have the first clue about web dev, JavaScript, and etc. I'd prefer to wrap it all up into a neat little executable.

Does this sound like a daunting task for a beginner, or do the more experienced coders out there think this might be a good project for me to get my beginning code on.

Link to comment
Share on other sites

It sounds as good as any to start on, but wondering if it'll depend on what I/O board you're using. I don't know much about hardware interfaces, but this might be a tricky bit.

I'd start with the game logic - that shouldn't be too difficult. From (painful) experience, I'd start with Visual Basic (either C# or VB.net - the latter's a little more beginner friendly) via Visual Studio Express (Free!). Then you could practice the game logic using timers, arrays and randoms via a form application. Place some buttons on a form and voila! Simon. :)

Then you'd just have to do the (potentially, although not sure) difficult bit of turning a change form-button event to a light LED event instead.

EDIT:

And if you want to cheat, here's a small bit of vb.net that runs simon:

Option Strict On
Option Explicit On
Public Class Form1
#Region "Variables"
Private pnl_list As New List(Of Panel)
Private play_list As New List(Of Panel)
Private game_tmr As New Timer
Private blink_tmr As New Timer
Private clicked_pnl As Panel
Private r As New Random
Private counter As Integer = 0
#End Region

#Region "Control Events"

Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Set the properties of me
With Me
.BackColor = Color.Black
.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedToolWindow
.Size = New Size(300, 300)
.StartPosition = FormStartPosition.CenterScreen
.Text = "Simon"
End With

'Set the game timer & blink timer intervals
game_tmr.Interval = 650
blink_tmr.Interval = 275

'Declare new instances of 4 panels
Dim pnl_blue, pnl_green, pnl_red, pnl_yellow As New Panel

'Add the panels to the list
pnl_list.AddRange({pnl_blue, pnl_green, pnl_red, pnl_yellow})

'Set the properties of the panels
With pnl_blue
.BackColor = Color.Blue
.Size = New Size(CInt(Me.Width / 2 - 2), CInt(Me.Height / 2 - 2))
.Location = New Point(0, 0)
.Tag = Color.Blue
.Name = "PanelBlue"
End With
With pnl_green
.BackColor = Color.Green
.Size = New Size(CInt(Me.Width / 2 - 2), CInt(Me.Height / 2 - 2))
.Location = New Point(CInt(Me.Width / 2 - 2), 0)
.Tag = Color.Green
.Name = "PanelGreen"
End With
With pnl_red
.BackColor = Color.Red
.Size = New Size(CInt(Me.Width / 2 - 2), CInt(Me.Height / 2 - 2))
.Location = New Point(0, CInt(Me.Height / 2 - 2))
.Tag = Color.Red
.Name = "PanelRed"
End With
With pnl_yellow
.BackColor = Color.Yellow
.Size = New Size(CInt(Me.Width / 2 - 2), CInt(Me.Height / 2 - 2))
.Location = New Point(CInt(Me.Width / 2 - 2), CInt(Me.Height / 2 - 2))
.Tag = Color.Yellow
.Name = "PanelYellow"
End With

'Add the panels to me
Me.Controls.AddRange(pnl_list.ToArray)

'Generate the click event for the 4 panels
For Each pnl As Panel In pnl_list
AddHandler pnl.Click, AddressOf Panel_Click
Next

'Generate the tick event for the two timers
AddHandler game_tmr.Tick, AddressOf GameTimer_Tick
AddHandler blink_tmr.Tick, AddressOf BlinkTimer_Tick

'Start a new game
Call AddItem()
game_tmr.Enabled = True
End Sub

Private Sub Panel_Click(sender As Object, e As EventArgs)
'If the timer isn't enabled then enable it
If blink_tmr.Enabled = False Then

'Set the clicked panel
clicked_pnl = DirectCast(sender, Panel)

'Change it's color
Select Case clicked_pnl.BackColor
Case Color.Blue
clicked_pnl.BackColor = Color.DarkBlue
Case Color.Green
clicked_pnl.BackColor = Color.DarkGreen
Case Color.Red
clicked_pnl.BackColor = Color.DarkRed
Case Color.Yellow
clicked_pnl.BackColor = Color.Gold
End Select

'Start the blink
blink_tmr.Enabled = True

'Check if the clicked panel is a match
If CheckMatch(clicked_pnl) Then
counter += 1
Else
counter = 0
MessageBox.Show("You guessed wrong. When you click OK a new game will start.", Me.Text, MessageBoxButtons.OK)
play_list.Clear()
Call AddItem()
game_tmr.Enabled = True
End If

'Check to see if we've guessed all the panels
If counter = play_list.Count Then
counter = 0
Call AddItem()
game_tmr.Enabled = True
End If
End If
End Sub

#End Region

#Region "Timers"

Private Sub GameTimer_Tick(sender As Object, e As EventArgs)
'Static i, or declare it as Private i outside of the sub
Static i As Integer = 0

'If i is less than the play_list count...
If i < play_list.Count Then
'Don't allow the panel's the be enabled
For Each pnl As Panel In pnl_list
pnl.Enabled = False
Next

'The panel to be clicked will be the current item in the list
clicked_pnl = play_list.Item(i)

'Change it's color
Select Case clicked_pnl.BackColor
Case Color.Blue
clicked_pnl.BackColor = Color.DarkBlue
Case Color.Green
clicked_pnl.BackColor = Color.DarkGreen
Case Color.Red
clicked_pnl.BackColor = Color.DarkRed
Case Color.Yellow
clicked_pnl.BackColor = Color.Gold
End Select

'Blink!
blink_tmr.Enabled = True

'Increment i by 1
i += 1
Else
'If i is equal to the playlist count...

'Set i back to 0
i = 0

'Stop the game timer
game_tmr.Enabled = False

'Set the panel's back to enabled
For Each pnl As Panel In pnl_list
pnl.Enabled = True
Next
End If
End Sub

Private Sub BlinkTimer_Tick(sender As Object, e As EventArgs)
'Stop the timer
blink_tmr.Enabled = False

'Set the panel's color back to it's original color
Select Case DirectCast(clicked_pnl.Tag, Color)
Case Color.Blue
clicked_pnl.BackColor = Color.Blue
Case Color.Green
clicked_pnl.BackColor = Color.Green
Case Color.Red
clicked_pnl.BackColor = Color.Red
Case Color.Yellow
clicked_pnl.BackColor = Color.Yellow
End Select

End Sub

#End Region

#Region "Private Subs/Functions"

Private Sub AddItem()
'Random int from 0 - 3
Dim i As Integer = r.Next(0, 4)

'Add the panel to the playlist
play_list.Add(pnl_list.Item(i))

End Sub

Private Function CheckMatch(ByVal pnl As Panel) As Boolean
If play_list.Item(counter).Name = pnl.Name Then
Return True
Else
Return False
End If
End Function

#End Region

End Class

http://www.vbforums.com/showthread.php?705623-vb-net-Simon

Main thing this shows is it isn't a huge bit of code - break it/add to it/examine it and it;'ll give you a feel for vb.net.

Good luck, brother!

Link to comment
Share on other sites

Yeah, thats nice. I'll admit that It's not completly greek to me, but most of the commands are. If I played around with it a bit I might be able to figure out what each section is responsable for. Wish they took the effort to add more explanatory text in the code.

Ultimarc's controlers also have compatability with LEDblinky and their own PACLED64 controller program. LED bliknky is popular for LED arcade buttons among MAME users. GameEX has a LEDwiz plugin too. I'm pretty unclear on how these work, but as I understand it they allow for LED CP profiles for various emulators and in MAME per game control layouts. I think these are separte from what I was talking about though, so I'd probably be stuck with the SDK and trying to Dev a program myself. Perhaps the first step would be to integrate the LED control Panel first using LEDwiz or LEDblinky first to familiarize myself with the programs.

The part I'd have real trouble with is adding button mapping in the 'Simon' game's user interface so you can map the games colored buttons to your control panel's LED or Colored Buttons. And of course sending lighting control out to the controller for LED illumination as you mentioned. Ultimarc links a PacDriveSDK for devs looking to control LEDs with a custom program, info here. It does support VB.net so there's a plus! This is probably what I would have to do and make the Simon game a stand alone game launched via executable. I've puttered around wit Visual Basic before, It was nice, but I was very out of my league. I had to look up commands for everything and how to do somthing basic, when what I wanted was much harder. We'll see though

PS:

The Readme says the Pac-DriveSDK dev is none other than Ben Baker (aka Headkaze)! LOL. Small world huh?

Link to comment
Share on other sites

I moved this topic from the general forum as it doesn't really fit there.

cintinued...

Well certainly sounds doable. Mapping your cab buttons will be ok, you just need a keyboard hook class. Plenty about. Dunno whats in the sdk, but if you have a dll or class to manage output then youll be golden.

The SDK has a bunch of utilitys I don't understand yet. But when I open the Demo control code, I can at least somewhat tell where it defines buttons, timers, and controler initilization. In the SDK zip there is a readme with controller commands to dev using a PACLED64, for example.

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _Partial Class Form1    Inherits System.Windows.Forms.Form    'Form overrides dispose to clean up the component list.    <System.Diagnostics.DebuggerNonUserCode()> _    Protected Overrides Sub Dispose(ByVal disposing As Boolean)        Try            If disposing AndAlso components IsNot Nothing Then                components.Dispose()            End If        Finally            MyBase.Dispose(disposing)        End Try    End Sub    'Required by the Windows Form Designer    Private components As System.ComponentModel.IContainer    'NOTE: The following procedure is required by the Windows Form Designer    'It can be modified using the Windows Form Designer.      'Do not modify it using the code editor.    <System.Diagnostics.DebuggerStepThrough()> _    Private Sub InitializeComponent()        Me.Button1 = New System.Windows.Forms.Button        Me.Button2 = New System.Windows.Forms.Button        Me.SuspendLayout()        '        'Button1        '        Me.Button1.Location = New System.Drawing.Point(12, 15)        Me.Button1.Name = "Button1"        Me.Button1.Size = New System.Drawing.Size(175, 35)        Me.Button1.TabIndex = 0        Me.Button1.Text = "Start"        Me.Button1.UseVisualStyleBackColor = True        '        'Button2        '        Me.Button2.Location = New System.Drawing.Point(12, 56)        Me.Button2.Name = "Button2"        Me.Button2.Size = New System.Drawing.Size(175, 35)        Me.Button2.TabIndex = 1        Me.Button2.Text = "Stop"        Me.Button2.UseVisualStyleBackColor = True        '        'Form1        '        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font        Me.ClientSize = New System.Drawing.Size(200, 108)        Me.Controls.Add(Me.Button2)        Me.Controls.Add(Me.Button1)        Me.Name = "Form1"        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen        Me.Text = "Form1"        Me.ResumeLayout(False)    End Sub    Friend WithEvents Button1 As System.Windows.Forms.Button    Friend WithEvents Button2 As System.Windows.Forms.ButtonEnd Class

If Im reading the code right. It makes a simple window displaying 2 buttons. I dont see where the buttons are defined as coming from a controller source (initilized or whatever the terminology is).

BTW:

what does this mean? "NOTE: The following procedure is required by the Windows Form Designer. It can be modified using the Windows Form Designer. Do not modify it using the code editor."

So I guess what I need to do is this:

  1. Find a way to hide a GUI config screen behind the game via some keypress (like TAB in mame). That way if you already have the buttons setup you don't see it when the game is run, instead it just goes to the start screen.
  2. Create a GUI config screen for adding buttons and placing them where the user wants (like in CPwiz). Adding custom backgrounds and button designs, etc. Simplified of course. I Just need to be able to define "Button1.Green = something like PACLED64 pins 1-3" The part where you input the pin position on the controller into code would be by simply pressing a control in the GUI for "Learn Green Button" which then allows you to press any button on your cab and the backend automatically parses it's loaction into the code. I have no idea how that's done, I'm a noob. I'm sure there's a class for that type of control though.
  3. Create the game logic, others have done this, so all I have to do is change the appearance of the lit buttons to match the button layout the user creates in the CPwiz style CP editor. The Button mapper would also have to parse the controler pin loaction into the button locations here too (unless you can tell it to get the button location from the config and go off whatever it was set to). The real issue would be compatability. How do I set it up to recognize any input device, so that whatever controller type the user has will be recognized by the button mapper?

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...

I made an arcade Joystick with integrated Simon Says Game. It used a Teensy++ 2.0 board, but I have also ported it to Arduino Leonardo. The project it published here:

https://www.hackster.io/user3853574654/arcade-joystick-x4-plus-simon-game-384309

You can see a video of the system working here:

https://www.youtube.com/watch?v=ENW7n0ni5kg&feature=youtu.be

cabinet.jpg

Link to comment
Share on other sites

  • 1 month later...

That's cool. I like how you integrated it into the credit counter so you have to defeat simon to get more credits to play Mame games. An intriguing idea to create that sense of accomplishment for going as far as possible on a single credit. That value is lost by unlimited credits at the push of a button. The only thing is that I'd like it selectable as a stand alone game and have some sort of animation to display onscreen to provide feedback about the simon game while running. A neat solution however.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...