Here are the screenshots of the Transformations Game on a Windows machine (in 2007).
Here are the resources of the Transformations Game (converted to .jpg and some renamed).
Here is the source code of the Transformations Game (in Visual Basic).
"Form 1":
' ---------------------------------------
'File: DonBurressMathProject
'Purpose: teach or reinforce transformational geometry skills by playing a game where
' students match a pre-image to an image using only translations,
' rotations, reflections or size transformations.
'Version: 8-22-2007 (not done version) VB.NET 2005
'Author: Don Burress
'Use: use and modify for non-commercial purposes, please acknowledge source
' ---------------------------------------
' import drawing stuff
Imports System.Drawing.Drawing2D
' import system stuff for sleep command
Imports System.Threading
Public Class Form1
'variable delcaration section
'set up drawing canvas
Private canvasLeft As Graphics
Private canvasRight As Graphics
Private hiddenCanvasLeft As Graphics
'background bitmap
Private background As Bitmap
'polygon arrays
Public leftPolygon(3) As Point
Public rightPolygon(3) As Point
'custom brushes and pens
Private polygonBrush As Brush
'grid variables
Public gridWidth As Decimal
Public gridHeight As Decimal
Public gridCenterX As Decimal
Public gridCenterY As Decimal
'random number generator
Private randomGenerator As Random
Private randomTransform As Integer
Private randomChoice As Integer
Private randomMagnitude As Decimal
Private userMagnitude As Decimal
Private userMagnitude2 As Decimal
Private MagnitudeX As Decimal
Private MagnitudeY As Decimal
Private MagnitudeX2 As Decimal
Private MagnitudeY2 As Decimal
Private randomX As Integer
Private randomY As Integer
Private randomTranslateX As Integer
Private randomTranslateY As Integer
Private translateX As Integer
Private translateY As Integer
Private translateX2 As Integer
Private translateY2 As Integer
'transformation variables
Private transformMatrix As Matrix
Private toOriginMatrix As Matrix
Private fromOriginMatrix As Matrix
'input values
Private userTranslateX As Integer
Private userTranslateY As Integer
Private buttonChoice As Integer
Private button2Choice As Integer
Private transformationChoice As Integer
Private userTranslateX2 As Integer
Private userTranslateY2 As Integer
Private transformationChoice2 As Integer
'win or loss animation variables
Private win As Boolean
Private happySprite As Bitmap
Private sadSprite As Bitmap
Private hiddenImage As Bitmap
Private x As Integer
Private y As Integer
Private xSpeed As Integer
Private ySpeed As Integer
Private userQuits As Boolean
Private frameX As Integer
Private frameWidth As Integer = 50
Private frameHeight As Integer = 50
Private frameRectangle As Rectangle
Private spriteScreenRectangle As Rectangle
Private slowAnimation As Integer
Private correctString As String
'level variable
Private level As Integer
'variables for transformation subroutines
Private i As Integer
Private temporaryX As Integer
Private temporaryY As Integer
'variables for sub-windows
Public answerForm As New Form2
Public scoreForm As New Form3
'variables for score
Public level1Correct As Integer
Public level2Correct As Integer
Public level3Correct As Integer
Public level4Correct As Integer
Public level5Correct As Integer
Public level1Played As Integer
Public level2Played As Integer
Public level3Played As Integer
Public level4Played As Integer
Public level5Played As Integer
Public totalScore As Integer
Private scoreIncrease As Integer
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
'hide the answer window
answerForm.Hide()
'stop the win/loss animation
animationTimer.Enabled = False
userQuits = True
player1.Ctlcontrols.stop()
answerForm.answerLabel.Text = ""
'debugLabel.Text = "level 5 does not work..."
debugLabel.Text = "choose a level"
'start canvases
canvasLeft = picLeft.CreateGraphics
canvasRight = picRight.CreateGraphics
'fix canvas labels if necessary
leftLabel.Text = "pre-image"
RightLabel.Text = "image"
'load and draw background image
background = New Bitmap("graph.bmp")
canvasLeft.DrawImage(background, 0, 0, picLeft.Width, picLeft.Height)
canvasRight.DrawImage(background, 0, 0, picRight.Width, picRight.Height)
' initialize grid variables
gridWidth = picLeft.Width / 40
gridHeight = -picLeft.Width / 40
gridCenterX = picLeft.Width / 2
gridCenterY = picLeft.Height / 2
' start random number generation (add time-based seed later)
randomGenerator = New Random()
' draw pre-image (weird 4-sided polygon)
polygonBrush = New SolidBrush(Color.FromArgb(50, 0, 0, 255))
'random point in quadrant 1
randomX = randomGenerator.Next(0, 9)
randomY = randomGenerator.Next(0, 9)
leftPolygon(0) = New Point(gridCenterX + randomX * gridWidth, gridCenterY + randomY * gridHeight)
'random point in quadrant 2
randomX = randomGenerator.Next(1, 9)
randomY = randomGenerator.Next(1, 9)
leftPolygon(1) = New Point(gridCenterX - randomX * gridWidth, gridCenterY + randomY * gridHeight)
'random point in quadrant 3
randomX = randomGenerator.Next(1, 9)
randomY = randomGenerator.Next(1, 9)
'random point in quadrant 4
leftPolygon(2) = New Point(gridCenterX - randomX * gridWidth, gridCenterY - randomY * gridHeight)
randomX = randomGenerator.Next(1, 9)
randomY = randomGenerator.Next(1, 9)
leftPolygon(3) = New Point(gridCenterX + randomX * gridWidth, gridCenterY - randomY * gridHeight)
'draw polygon on left canvas
canvasLeft.FillPolygon(polygonBrush, leftPolygon)
canvasLeft.DrawPolygon(Pens.Black, leftPolygon)
'change start button, enable level buttons
btnStart.Text = "Start" & vbNewLine & "Over"
btnLevel1.Enabled = True
btnLevel2.Enabled = True
btnLevel3.Enabled = True
btnLevel4.Enabled = True
'btnLevel5.Enabled = True
'disable transformation buttons
btnTranslate.Enabled = False
btnReflect.Enabled = False
btnRotate.Enabled = False
btnSizeTransform.Enabled = False
btnTranslate2.Enabled = False
btnReflect2.Enabled = False
btnRotate2.Enabled = False
btnSizeTransform2.Enabled = False
btnTranslate2.Visible = False
btnReflect2.Visible = False
btnRotate2.Visible = False
btnSizeTransform2.Visible = False
'disable extraneous options
reflectionBox1.Visible = False
rotationBox1.Visible = False
MagnitudeBox1.Visible = False
translationBox1.Visible = False
reflectionBox2.Visible = False
rotationBox2.Visible = False
MagnitudeBox2.Visible = False
translationBox2.Visible = False
'hide coordinate stuff
coordBox1.Visible = False
coordBox2.Visible = False
End Sub
Private Sub btnLevel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevel1.Click
'level 1 game
level = 1
debugLabel.Text = "describe the correct transformation"
'choose random transformation
randomTransform = randomGenerator.Next(1, 9.9)
If randomTransform = 1 Then
'create random translation
randomX = randomGenerator.Next(-5, 5.9)
randomY = randomGenerator.Next(-5, 5.9)
'debugLabel.Text = "translation: x-shift= " & randomX & " y-shift= " & randomY & " " & randomTransform
randomTranslateX = randomX * gridWidth
randomTranslateY = randomY * gridHeight
translateX = randomTranslateX
translateY = randomTranslateY
correctString = "translate with x-shift= " & randomX & " and y-shift= " & randomY
ElseIf randomTransform = 2 Then
'debugLabel.Text = "reflect over x-axis " & randomTransform
correctString = "reflect over x-axis "
ElseIf randomTransform = 3 Then
'debugLabel.Text = "reflect over y-axis " & randomTransform
correctString = "reflect over y-axis "
ElseIf randomTransform = 4 Then
'debugLabel.Text = "reflect over y = x " & randomTransform
correctString = "reflect over y = x "
ElseIf randomTransform = 5 Then
'debugLabel.Text = "reflect over y = -x " & randomTransform
correctString = "reflect over y = -x "
ElseIf randomTransform = 6 Then
'debugLabel.Text = "rotate 90 CW " & randomTransform
correctString = "rotate 90 clockwise "
ElseIf randomTransform = 7 Then
'debugLabel.Text = "rotate 180 " & randomTransform
correctString = "rotate 180 "
ElseIf randomTransform = 8 Then
'debugLabel.Text = "rotate 90 CCW " & randomTransform
correctString = "rotate 90 counter-clockwise "
ElseIf randomTransform = 9 Then
randomChoice = randomGenerator.Next(1, 6.9)
randomMagnitude = randomChoice / 2
MagnitudeX = randomMagnitude
MagnitudeY = randomMagnitude
'debugLabel.Text = "random size transformation magnitude " & randomMagnitude & " " & randomTransform
correctString = "size transformation, magnitude " & randomMagnitude
End If
' draw transformation on right canvas
For i = 0 To 3
rightPolygon(i).X = leftPolygon(i).X
rightPolygon(i).Y = leftPolygon(i).Y
Next i
rightTransform(randomTransform)
'draw polygon on right canvas
canvasRight.FillPolygon(polygonBrush, rightPolygon)
canvasRight.DrawPolygon(Pens.Black, rightPolygon)
'enable transformation buttons
btnTranslate.Visible = True
btnTranslate.Enabled = True
btnReflect.Visible = True
btnReflect.Enabled = True
btnRotate.Visible = True
btnRotate.Enabled = True
btnSizeTransform.Visible = True
btnSizeTransform.Enabled = True
'disable level buttons (stuck in level until "start over" occurs)
btnLevel1.Enabled = False
btnLevel2.Enabled = False
btnLevel3.Enabled = False
btnLevel4.Enabled = False
btnLevel5.Enabled = False
End Sub
Private Sub btnLevel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevel2.Click
' level 2
level = 2
debugLabel.Text = "describe the correct transformation"
'disable level buttons (stuck in level until "start over" occurs)
btnLevel1.Enabled = False
btnLevel2.Enabled = False
btnLevel3.Enabled = False
btnLevel4.Enabled = False
btnLevel5.Enabled = False
'hide transformation buttons
btnTranslate.Visible = False
btnRotate.Visible = False
btnReflect.Visible = False
btnSizeTransform.Visible = False
'make coordinate stuff visible
coordBox1.Visible = True
coordLabel.Visible = True
coordLabel2.Visible = True
coordLabel3.Visible = True
coordLabel4.Visible = True
coordLabel5.Visible = True
coordLabel6.Visible = True
coordLabel7.Visible = True
coordBoxX.Visible = True
coordBoxX.SelectedItem = "x"
coordBoxY.Visible = True
coordBoxY.SelectedItem = "y"
addXBox.Visible = True
addXBox.SelectedItem = "0"
addYBox.Visible = True
addYBox.SelectedItem = "0"
multXBox.Visible = True
multXBox.SelectedItem = "1"
multYBox.Visible = True
multYBox.SelectedItem = "1"
'choose random transformation
randomChoice = 0
randomTransform = randomGenerator.Next(1, 9.9)
If randomTransform = 1 Then
'create random translation
randomX = randomGenerator.Next(-5, 5.9)
randomY = randomGenerator.Next(-5, 5.9)
debugLabel.Text = "translation: x-shift= " & randomX & " y-shift= " & randomY & " " & randomTransform
translateX = randomX * gridWidth
translateY = randomY * gridHeight
randomTranslateX = translateX
randomTranslateY = translateY
'correctString = "translate with x-shift= " & randomX & " and y-shift= " & randomY
ElseIf randomTransform = 2 Then
'debugLabel.Text = "reflect over x-axis " & randomTransform
'correctString = "reflect over x-axis "
ElseIf randomTransform = 3 Then
'debugLabel.Text = "reflect over y-axis " & randomTransform
'correctString = "reflect over y-axis "
ElseIf randomTransform = 4 Then
'debugLabel.Text = "reflect over y = x " & randomTransform
'correctString = "reflect over y = x "
ElseIf randomTransform = 5 Then
'do reflection over y = -x
'debugLabel.Text = "reflect over y = -x " & randomTransform
'correctString = "reflect over y = -x "
ElseIf randomTransform = 6 Then
'debugLabel.Text = "rotate 90 CW " & randomTransform
'correctString = "rotate 90 clockwise "
ElseIf randomTransform = 7 Then
'debugLabel.Text = "rotate 180 " & randomTransform
'correctString = "rotate 180 "
ElseIf randomTransform = 8 Then
'debugLabel.Text = "rotate 90 CCW " & randomTransform
'correctString = "rotate 90 counter-clockwise "
ElseIf randomTransform = 9 Then
randomChoice = randomGenerator.Next(1, 6.9)
randomMagnitude = randomChoice / 2
MagnitudeX = randomMagnitude
MagnitudeY = randomMagnitude
'debugLabel.Text = "random size transformation magnitude " & randomMagnitude & " " & randomTransform
'correctString = "size transformation, magnitude " & randomMagnitude
End If
' draw transformation on right canvas
For i = 0 To 3
rightPolygon(i).X = leftPolygon(i).X
rightPolygon(i).Y = leftPolygon(i).Y
Next i
rightTransform(randomTransform)
'draw polygon on right canvas
canvasRight.FillPolygon(polygonBrush, rightPolygon)
canvasRight.DrawPolygon(Pens.Black, rightPolygon)
'enable submit button
btnSubmit.Enabled = True
End Sub
Private Sub btnLevel3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevel3.Click
' level 3
level = 3
debugLabel.Text = "describe the correct composition of 2 transformations"
randomTransform = randomGenerator.Next(1, 9.9)
If randomTransform = 1 Then
'create random translation
randomX = randomGenerator.Next(-5, 5.9)
randomY = randomGenerator.Next(-5, 5.9)
'debugLabel.Text = "translation: x-shift= " & randomX & " y-shift= " & randomY & " " & randomTransform
randomTranslateX = randomX * gridWidth
randomTranslateY = randomY * gridHeight
translateX = randomTranslateX
translateY = randomTranslateY
correctString = "translate with x-shift= " & randomX & " and y-shift= " & randomY
ElseIf randomTransform = 2 Then
'debugLabel.Text = "reflect over x-axis " & randomTransform
correctString = "reflect over x-axis "
ElseIf randomTransform = 3 Then
'debugLabel.Text = "reflect over y-axis " & randomTransform
correctString = "reflect over y-axis "
ElseIf randomTransform = 4 Then
'debugLabel.Text = "reflect over y = x " & randomTransform
correctString = "reflect over y = x "
ElseIf randomTransform = 5 Then
'debugLabel.Text = "reflect over y = -x " & randomTransform
correctString = "reflect over y = -x "
ElseIf randomTransform = 6 Then
'debugLabel.Text = "rotate 90 CW " & randomTransform
correctString = "rotate 90 clockwise "
ElseIf randomTransform = 7 Then
'debugLabel.Text = "rotate 180 " & randomTransform
correctString = "rotate 180 "
ElseIf randomTransform = 8 Then
'debugLabel.Text = "rotate 90 CCW " & randomTransform
correctString = "rotate 90 counter-clockwise "
ElseIf randomTransform = 9 Then
randomChoice = randomGenerator.Next(1, 6.9)
randomMagnitude = randomChoice / 2
MagnitudeX = randomMagnitude
MagnitudeY = randomMagnitude
'debugLabel.Text = "random size transformation magnitude " & randomMagnitude & " " & randomTransform
correctString = "size transformation, magnitude " & randomMagnitude
End If
' transform right polygon first time
For i = 0 To 3
rightPolygon(i).X = leftPolygon(i).X
rightPolygon(i).Y = leftPolygon(i).Y
Next i
rightTransform(randomTransform)
randomTransform = randomGenerator.Next(1, 8.9)
If randomTransform = 1 Then
'create random translation
randomX = randomGenerator.Next(-10, 10.9)
randomY = randomGenerator.Next(-10, 10.9)
'debugLabel.Text = "translation: x-shift= " & randomX & " y-shift= " & randomY & " " & randomTransform
randomTranslateX = randomX * gridWidth
randomTranslateY = randomY * gridHeight
translateX = randomTranslateX
translateY = randomTranslateY
correctString = correctString & vbNewLine & "then " & vbNewLine & "translate with x-shift= " & randomX & " and y-shift= " & randomY
ElseIf randomTransform = 2 Then
'debugLabel.Text = "reflect over x-axis " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over x-axis "
ElseIf randomTransform = 3 Then
'debugLabel.Text = "reflect over y-axis " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over y-axis "
ElseIf randomTransform = 4 Then
'debugLabel.Text = "reflect over y = x " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over y = x "
ElseIf randomTransform = 5 Then
'debugLabel.Text = "reflect over y = -x " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over y = -x "
ElseIf randomTransform = 6 Then
'debugLabel.Text = "rotate 90 CW " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "rotate 90 clockwise "
ElseIf randomTransform = 7 Then
'debugLabel.Text = "rotate 180 " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "rotate 180 "
ElseIf randomTransform = 8 Then
'debugLabel.Text = "rotate 90 CCW " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "rotate 90 counter-clockwise "
End If
'transform it a second time
rightTransform(randomTransform)
'draw polygon on right canvas
canvasRight.FillPolygon(polygonBrush, rightPolygon)
canvasRight.DrawPolygon(Pens.Black, rightPolygon)
'enable transformation buttons
btnTranslate.Visible = True
btnTranslate.Enabled = True
btnReflect.Visible = True
btnReflect.Enabled = True
btnRotate.Visible = True
btnRotate.Enabled = True
btnSizeTransform.Visible = True
btnSizeTransform.Enabled = True
btnTranslate2.Visible = True
btnTranslate2.Enabled = True
btnReflect2.Visible = True
btnReflect2.Enabled = True
btnRotate2.Visible = True
btnRotate2.Enabled = True
btnSizeTransform2.Visible = True
btnSizeTransform2.Enabled = True
'disable level buttons (stuck in level until "start over" occurs)
btnLevel1.Enabled = False
btnLevel2.Enabled = False
btnLevel3.Enabled = False
btnLevel4.Enabled = False
btnLevel5.Enabled = False
End Sub
Private Sub btnLevel4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevel4.Click
' level 4
level = 4
debugLabel.Text = "describe the correct composition of 2 transformations"
'disable level buttons (stuck in level until "start over" occurs)
btnLevel1.Enabled = False
btnLevel2.Enabled = False
btnLevel3.Enabled = False
btnLevel4.Enabled = False
btnLevel5.Enabled = False
'hide transformation buttons
btnTranslate.Visible = False
btnRotate.Visible = False
btnReflect.Visible = False
btnSizeTransform.Visible = False
'make coordinate stuff visible
coordBox1.Visible = True
coordLabel.Visible = True
coordLabel2.Visible = True
coordLabel3.Visible = True
coordLabel4.Visible = True
coordLabel5.Visible = True
coordLabel6.Visible = True
coordLabel7.Visible = True
coordBoxX.Visible = True
coordBoxX.SelectedItem = "x"
coordBoxY.Visible = True
coordBoxY.SelectedItem = "y"
addXBox.Visible = True
addXBox.SelectedItem = "0"
addYBox.Visible = True
addYBox.SelectedItem = "0"
multXBox.Visible = True
multXBox.SelectedItem = "1"
multYBox.Visible = True
multYBox.SelectedItem = "1"
coordBox2.Visible = True
coordLabel8.Visible = True
coordLabel9.Visible = True
coordLabel10.Visible = True
coordLabel11.Visible = True
coordLabel12.Visible = True
coordLabel13.Visible = True
coordLabel14.Visible = True
coordBoxX2.Visible = True
coordBoxX2.SelectedItem = "x"
coordBoxY2.Visible = True
coordBoxY2.SelectedItem = "y"
addXBox2.Visible = True
addXBox2.SelectedItem = "0"
addYBox2.Visible = True
addYBox2.SelectedItem = "0"
multXBox2.Visible = True
multXBox2.SelectedItem = "1"
multYBox2.Visible = True
multYBox2.SelectedItem = "1"
'choose random transformation
randomChoice = 0
randomTransform = randomGenerator.Next(1, 9.9)
If randomTransform = 1 Then
'create random translation
randomX = randomGenerator.Next(-5, 5.9)
randomY = randomGenerator.Next(-5, 5.9)
'debugLabel.Text = "translation: x-shift= " & randomX & " y-shift= " & randomY & " " & randomTransform
translateX = randomX * gridWidth
translateY = randomY * gridHeight
randomTranslateX = translateX
randomTranslateY = translateY
correctString = "translate with x-shift= " & randomX & " and y-shift= " & randomY
ElseIf randomTransform = 2 Then
'debugLabel.Text = "reflect over x-axis " & randomTransform
correctString = "reflect over x-axis "
ElseIf randomTransform = 3 Then
'debugLabel.Text = "reflect over y-axis " & randomTransform
correctString = "reflect over y-axis "
ElseIf randomTransform = 4 Then
'debugLabel.Text = "reflect over y = x " & randomTransform
correctString = "reflect over y = x "
ElseIf randomTransform = 5 Then
'do reflection over y = -x
'debugLabel.Text = "reflect over y = -x " & randomTransform
correctString = "reflect over y = -x "
ElseIf randomTransform = 6 Then
'debugLabel.Text = "rotate 90 CW " & randomTransform
correctString = "rotate 90 clockwise "
ElseIf randomTransform = 7 Then
'debugLabel.Text = "rotate 180 " & randomTransform
correctString = "rotate 180 "
ElseIf randomTransform = 8 Then
'debugLabel.Text = "rotate 90 CCW " & randomTransform
correctString = "rotate 90 counter-clockwise "
ElseIf randomTransform = 9 Then
randomChoice = randomGenerator.Next(1, 6.9)
randomMagnitude = randomChoice / 2
MagnitudeX = randomMagnitude
MagnitudeY = randomMagnitude
'debugLabel.Text = "random size transformation magnitude " & randomMagnitude & " " & randomTransform
correctString = "size transformation, magnitude " & randomMagnitude
End If
' draw transformation on right canvas
For i = 0 To 3
rightPolygon(i).X = leftPolygon(i).X
rightPolygon(i).Y = leftPolygon(i).Y
Next i
rightTransform(randomTransform)
randomTransform = randomGenerator.Next(1, 8.9)
If randomTransform = 1 Then
'create random translation
randomX = randomGenerator.Next(-10, 10.9)
randomY = randomGenerator.Next(-10, 10.9)
'debugLabel.Text = "translation: x-shift= " & randomX & " y-shift= " & randomY & " " & randomTransform
randomTranslateX = randomX * gridWidth
randomTranslateY = randomY * gridHeight
translateX = randomTranslateX
translateY = randomTranslateY
correctString = correctString & vbNewLine & "then " & vbNewLine & "translate with x-shift= " & randomX & " and y-shift= " & randomY
ElseIf randomTransform = 2 Then
'debugLabel.Text = "reflect over x-axis " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over x-axis "
ElseIf randomTransform = 3 Then
'debugLabel.Text = "reflect over y-axis " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over y-axis "
ElseIf randomTransform = 4 Then
'debugLabel.Text = "reflect over y = x " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over y = x "
ElseIf randomTransform = 5 Then
'debugLabel.Text = "reflect over y = -x " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "reflect over y = -x "
ElseIf randomTransform = 6 Then
'debugLabel.Text = "rotate 90 CW " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "rotate 90 clockwise "
ElseIf randomTransform = 7 Then
'debugLabel.Text = "rotate 180 " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "rotate 180 "
ElseIf randomTransform = 8 Then
'debugLabel.Text = "rotate 90 CCW " & randomTransform
correctString = correctString & vbNewLine & "then " & vbNewLine & "rotate 90 counter-clockwise "
End If
'transform it a second time
rightTransform(randomTransform)
'draw polygon on right canvas
canvasRight.FillPolygon(polygonBrush, rightPolygon)
canvasRight.DrawPolygon(Pens.Black, rightPolygon)
'enable submit button
btnSubmit.Enabled = True
End Sub
Private Sub btnLevel5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevel5.Click
' level 5
level = 5
debugLabel.Text = "(this is level 5: level 1 with matrix model only)"
'disable level buttons (stuck in level until "start over" occurs)
btnLevel1.Enabled = False
btnLevel2.Enabled = False
btnLevel3.Enabled = False
btnLevel4.Enabled = False
btnLevel5.Enabled = False
End Sub
Private Sub btnTranslate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTranslate.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
reflectionBox1.Visible = False
rotationBox1.Visible = False
MagnitudeBox1.Visible = False
'enable shift controls
translationBox1.Visible = True
horizontalShiftLabel.Visible = True
horizontalShiftChoice.Visible = True
verticalShiftLabel.Visible = True
verticalShiftChoice.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
buttonChoice = 1
End Sub
Private Sub btnTranslate2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTranslate2.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
reflectionBox2.Visible = False
rotationBox2.Visible = False
MagnitudeBox2.Visible = False
'enable shift controls
translationBox2.Visible = True
horizontalShiftLabel2.Visible = True
horizontalShiftChoice2.Visible = True
verticalShiftLabel2.Visible = True
VerticalShiftChoice2.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
button2Choice = 1
End Sub
Private Sub btnReflect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReflect.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
translationBox1.Visible = False
rotationBox1.Visible = False
MagnitudeBox1.Visible = False
'enable reflection choices
reflectionBox1.Visible = True
radioX.Visible = True
radioY.Visible = True
radioYX.Visible = True
radioNegativeX.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
buttonChoice = 2
End Sub
Private Sub btnReflect2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReflect2.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
translationBox2.Visible = False
rotationBox2.Visible = False
MagnitudeBox2.Visible = False
'enable reflection choices
radioX2.Visible = True
radioY2.Visible = True
radioYX2.Visible = True
radioNegativeX2.Visible = True
reflectionBox2.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
button2Choice = 2
End Sub
Private Sub btnRotate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotate.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
translationBox1.Visible = False
reflectionBox1.Visible = False
MagnitudeBox1.Visible = False
'enable rotation choices
rotationBox1.Visible = True
radio90CW.Visible = True
radio90CCW.Visible = True
radio180.Visible = True
radio270CW.Visible = True
radio270CCW.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
buttonChoice = 3
End Sub
Private Sub btnRotate2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotate2.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
translationBox2.Visible = False
reflectionBox2.Visible = False
MagnitudeBox2.Visible = False
'enable rotation choices
rotationBox2.Visible = True
radio90CW2.Visible = True
radio90CCW2.Visible = True
radio1802.Visible = True
radio270CW2.Visible = True
radio270CCW2.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
button2Choice = 3
End Sub
Private Sub btnSizeTransform_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSizeTransform.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
translationBox1.Visible = False
reflectionBox1.Visible = False
rotationBox1.Visible = False
'enable magnitude choices
MagnitudeBox1.Visible = True
magnitudeLabel.Visible = True
magnitudeChoice.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
buttonChoice = 4
End Sub
Private Sub btnSizeTransform2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSizeTransform2.Click
'enable submit button, disable extraneous options
btnSubmit.Enabled = True
translationBox2.Visible = False
reflectionBox2.Visible = False
rotationBox2.Visible = False
'enable magnitude choices
MagnitudeBox2.Visible = True
magnitudeLabel2.Visible = True
magnitudeChoice2.Visible = True
'tell program what button is chosen 1=translate, 2=reflect, 3=rotate, 4=size
button2Choice = 4
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'disable shift controls
reflectionBox1.Visible = False
rotationBox1.Visible = False
MagnitudeBox1.Visible = False
translationBox1.Visible = False
ReflectionBox2.Visible = False
RotationBox2.Visible = False
MagnitudeBox2.Visible = False
translationBox2.Visible = False
'disable transform buttons
btnTranslate.Enabled = False
btnReflect.Enabled = False
btnRotate.Enabled = False
btnSizeTransform.Enabled = False
btnTranslate2.Enabled = False
btnReflect2.Enabled = False
btnRotate2.Enabled = False
btnSizeTransform2.Enabled = False
'hide coordinate stuff
coordBox1.Visible = False
coordBox2.Visible = False
'perform their transformation based on their button choice (level 1 checking)
If buttonChoice = 1 Then
'draw translation
'transform shape, changing pre-image to their image
userTranslateX = horizontalShiftChoice.SelectedItem
userTranslateY = verticalShiftChoice.SelectedItem
translateX = userTranslateX * gridWidth
translateY = userTranslateY * gridHeight
transformationChoice = 1
ElseIf buttonChoice = 2 Then
'draw reflection
If radioX.Checked Then
'reflect over x-axis
transformationChoice = 2
ElseIf radioY.Checked Then
'reflect over y-axis
transformationChoice = 3
ElseIf radioYX.Checked Then
'reflect over y = x
transformationChoice = 4
ElseIf radioNegativeX.Checked Then
'reflect over y = -x
transformationChoice = 5
End If
ElseIf buttonChoice = 3 Then
'draw rotation
If radio90CW.Checked Or radio270CCW.Checked Then
transformationChoice = 6
ElseIf radio90CCW.Checked Or radio270CW.Checked Then
transformationChoice = 8
ElseIf radio180.Checked Then
transformationChoice = 7
End If
ElseIf buttonChoice = 4 Then
'draw size transformation
transformationChoice = 9
userMagnitude = magnitudeChoice.SelectedItem
MagnitudeX = userMagnitude
MagnitudeY = userMagnitude
End If
'perform their transformation based on their button choice (level 3 checking)
If button2Choice = 1 Then
'draw translation
'transform shape, changing pre-image to their image
userTranslateX2 = horizontalShiftChoice2.SelectedItem
userTranslateY2 = VerticalShiftChoice2.SelectedItem
translateX2 = userTranslateX2 * gridWidth
translateY2 = userTranslateY2 * gridHeight
transformationChoice2 = 1
ElseIf button2Choice = 2 Then
'draw reflection
If radioX.Checked Then
'reflect over x-axis
transformationChoice2 = 2
ElseIf radioY.Checked Then
'reflect over y-axis
transformationChoice2 = 3
ElseIf radioYX.Checked Then
'reflect over y = x
transformationChoice2 = 4
ElseIf radioNegativeX.Checked Then
'reflect over y = -x
transformationChoice2 = 5
End If
ElseIf button2Choice = 3 Then
'draw rotation
If radio90CW.Checked Or radio270CCW.Checked Then
transformationChoice2 = 6
ElseIf radio90CCW.Checked Or radio270CW.Checked Then
transformationChoice2 = 8
ElseIf radio180.Checked Then
transformationChoice2 = 7
End If
ElseIf button2Choice = 4 Then
'draw size transformation
transformationChoice2 = 9
userMagnitude2 = magnitudeChoice2.SelectedItem
MagnitudeX2 = userMagnitude2
MagnitudeY2 = userMagnitude2
End If
'do user transformation (level 2 or 4 only)
If level = 2 Or level = 4 Then
If coordBoxX.SelectedItem = "x" And coordBoxY.SelectedItem = "y" Then
If addXBox.SelectedItem <> 0 Or addYBox.SelectedItem <> 0 Then
'translation with
transformationChoice = 1
userTranslateX = addXBox.SelectedItem
userTranslateY = addYBox.SelectedItem
translateX = userTranslateX * gridWidth
translateY = userTranslateY * gridHeight
ElseIf addXBox.SelectedItem = 0 And addYBox.SelectedItem = 0 Then
'size transformation
transformationChoice = 9
If multXBox.SelectedItem = multYBox.SelectedItem Then
' correct form of size transformation
userMagnitude = multXBox.SelectedItem
Else
'incorrect form of size transformation
userMagnitude = 0
End If
MagnitudeX = multXBox.SelectedItem
MagnitudeY = multYBox.SelectedItem
End If
ElseIf coordBoxX.SelectedItem = "x" And coordBoxY.SelectedItem = "-y" Then
'reflect over x-axis
transformationChoice = 2
ElseIf coordBoxX.SelectedItem = "-x" And coordBoxY.SelectedItem = "y" Then
'reflect over y-axis
transformationChoice = 3
ElseIf coordBoxX.SelectedItem = "y" And coordBoxY.SelectedItem = "x" Then
'reflect over y = x
transformationChoice = 4
ElseIf coordBoxX.SelectedItem = "-y" And coordBoxY.SelectedItem = "-x" Then
'reflect over y = -x
transformationChoice = 5
ElseIf coordBoxX.SelectedItem = "-y" And coordBoxY.SelectedItem = "x" Then
'rotate 90CW
transformationChoice = 6
ElseIf coordBoxX.SelectedItem = "-x" And coordBoxY.SelectedItem = "-y" Then
'rotate 180
transformationChoice = 7
ElseIf coordBoxX.SelectedItem = "y" And coordBoxY.SelectedItem = "-x" Then
'rotate 90CCW
transformationChoice = 8
End If
End If
'do user transformation (level 4 only)
If level = 4 Then
If coordBoxX2.SelectedItem = "x" And coordBoxY2.SelectedItem = "y" Then
If addXBox2.SelectedItem <> 0 Or addYBox2.SelectedItem <> 0 Then
'translation with
transformationChoice2 = 1
userTranslateX2 = addXBox2.SelectedItem
userTranslateY2 = addYBox2.SelectedItem
translateX2 = userTranslateX2 * gridWidth
translateY2 = userTranslateY2 * gridHeight
ElseIf addXBox2.SelectedItem = 0 And addYBox2.SelectedItem = 0 Then
'size transformation
transformationChoice2 = 9
If multXBox2.SelectedItem = multYBox2.SelectedItem Then
' correct form of size transformation
userMagnitude2 = multXBox2.SelectedItem
Else
'incorrect form of size transformation
userMagnitude2 = 0
End If
MagnitudeX2 = multXBox2.SelectedItem
MagnitudeY2 = multYBox2.SelectedItem
End If
ElseIf coordBoxX2.SelectedItem = "x" And coordBoxY2.SelectedItem = "-y" Then
'reflect over x-axis
transformationChoice2 = 2
ElseIf coordBoxX2.SelectedItem = "-x" And coordBoxY2.SelectedItem = "y" Then
'reflect over y-axis
transformationChoice2 = 3
ElseIf coordBoxX2.SelectedItem = "y" And coordBoxY2.SelectedItem = "x" Then
'reflect over y = x
transformationChoice2 = 4
ElseIf coordBoxX2.SelectedItem = "-y" And coordBoxY2.SelectedItem = "-x" Then
'reflect over y = -x
transformationChoice2 = 5
ElseIf coordBoxX2.SelectedItem = "-y" And coordBoxY2.SelectedItem = "x" Then
'rotate 90CW
transformationChoice2 = 6
ElseIf coordBoxX2.SelectedItem = "-x" And coordBoxY2.SelectedItem = "-y" Then
'rotate 180
transformationChoice2 = 7
ElseIf coordBoxX2.SelectedItem = "y" And coordBoxY2.SelectedItem = "-x" Then
'rotate 90CCW
transformationChoice2 = 8
End If
End If
' re-draw left canvas
canvasLeft.DrawImage(background, 0, 0, picLeft.Width, picLeft.Height)
' do transformation
leftTransform(transformationChoice)
' do second transformation (if level 3 or 4)
If level = 3 Or level = 4 Then
leftTransform2(transformationChoice2)
End If
'check values (all levels)
win = True
For i = 0 To 3
If (leftPolygon.GetValue(i) <> rightPolygon.GetValue(i)) Then
win = False
End If
Next i
'change score and game played variables
If level = 1 Then
level1Played = level1Played + 1
scoreForm.playedLabel1.Text = level1Played
ElseIf level = 2 Then
level2Played = level2Played + 1
scoreForm.playedLabel2.Text = level2Played
ElseIf level = 3 Then
level3Played = level3Played + 1
scoreForm.playedLabel3.Text = level3Played
ElseIf level = 4 Then
level4Played = level4Played + 1
scoreForm.playedLabel4.Text = level4Played
ElseIf level = 5 Then
level5Played = level5Played + 1
scoreForm.playedLabel5.Text = level5Played
End If
If win Then
If level = 1 Then
level1Correct = level1Correct + 1
scoreForm.correctLabel1.Text = level1Correct
scoreIncrease = 1
ElseIf level = 2 Then
level2Correct = level2Correct + 1
scoreForm.correctLabel2.Text = level2Correct
scoreIncrease = 2
ElseIf level = 3 Then
level3Correct = level3Correct + 1
scoreForm.correctLabel3.Text = level3Correct
scoreIncrease = 3
ElseIf level = 4 Then
level4Correct = level4Correct + 1
scoreForm.correctLabel4.Text = level4Correct
scoreIncrease = 4
ElseIf level = 5 Then
level5Correct = level5Correct + 1
scoreForm.correctLabel5.Text = level5Correct
scoreIncrease = 5
End If
Else
scoreIncrease = -1
End If
'calculate total score
totalScore = totalScore + scoreIncrease
scoreForm.totalScoreLabel.Text = totalScore
'show score window
scoreForm.Show()
Me.Focus()
' set up brushes for user transformation. red for loss, green for win.
If win Then
polygonBrush = New SolidBrush(Color.FromArgb(50, 0, 255, 0))
Else
polygonBrush = New SolidBrush(Color.FromArgb(50, 255, 0, 0))
End If
'draw shape (color dependent on correctness)
leftLabel.Text = "your image"
RightLabel.Text = "correct image"
canvasLeft.FillPolygon(polygonBrush, leftPolygon)
canvasLeft.DrawPolygon(Pens.Black, leftPolygon)
'initialize animation for win/loss
animationTimer.Enabled = True
hiddenCanvasLeft = picLeft.CreateGraphics
hiddenImage = New Bitmap(picLeft.Width, picLeft.Height)
hiddenCanvasLeft = Graphics.FromImage(hiddenImage)
'set up animation variables
xSpeed = randomGenerator.Next(-5, 5)
ySpeed = randomGenerator.Next(-5, 5)
userQuits = False
If win Then
'play winning song
debugLabel.Text = "You got it!"
'setup sprite
happySprite = New Bitmap("happy.bmp")
happySprite.MakeTransparent(Color.White)
'draw sprite
x = gridCenterX - happySprite.Width / 2
y = gridCenterY - happySprite.Height / 2
hiddenCanvasLeft.DrawImage(happySprite, x, y)
canvasLeft.DrawImage(hiddenImage, 0, 0)
Else
'play losing song
answerForm.Show()
Me.Focus()
debugLabel.Text = "Sorry!"
answerForm.answerLabel.Text = correctString
'setup sprite
sadSprite = New Bitmap("sad.bmp")
sadSprite.MakeTransparent(Color.White)
'draw sprite
x = gridCenterX - frameWidth / 2
y = gridCenterY - frameHeight / 2
frameX = 0
slowAnimation = 0
frameRectangle = New Rectangle(frameX, 0, frameWidth, frameHeight)
spriteScreenRectangle = New Rectangle(x, y, 50, 50)
hiddenCanvasLeft.DrawImage(sadSprite, spriteScreenRectangle, frameRectangle, GraphicsUnit.Pixel)
canvasLeft.DrawImage(hiddenImage, 0, 0)
End If
'make submit label go away and make start button enabled
btnSubmit.Enabled = False
btnStart.Enabled = True
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
userQuits = True
player1.Ctlcontrols.stop()
End Sub
Private Sub animationTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles animationTimer.Tick
animationTimer.Enabled = False
'win/loss animation/sound
If win Then
'do win animation
Do
'redraw background
hiddenCanvasLeft.DrawImage(background, 0, 0, picLeft.Width, picLeft.Height)
'redraw polygon
hiddenCanvasLeft.FillPolygon(polygonBrush, leftPolygon)
hiddenCanvasLeft.DrawPolygon(Pens.Black, leftPolygon)
'draw sprite
hiddenCanvasLeft.DrawImage(happySprite, x, y)
canvasLeft.DrawImage(hiddenImage, 0, 0)
x = x + xSpeed
y = y + ySpeed
If x <= 0 Then
xSpeed = randomGenerator.Next(1, 5)
ElseIf x >= picLeft.Width - happySprite.Width Then
xSpeed = randomGenerator.Next(-5, 1)
ElseIf y <= 0 Then
ySpeed = randomGenerator.Next(1, 5)
ElseIf y >= picLeft.Height - happySprite.Height Then
ySpeed = randomGenerator.Next(-5, 1)
End If
Thread.Sleep(30)
Application.DoEvents()
Loop Until userQuits
Else
'do sad face animation
Do
'redraw background
hiddenCanvasLeft.DrawImage(background, 0, 0, picLeft.Width, picLeft.Height)
'redraw polygon
hiddenCanvasLeft.FillPolygon(polygonBrush, leftPolygon)
hiddenCanvasLeft.DrawPolygon(Pens.Black, leftPolygon)
'draw sprite
hiddenCanvasLeft.DrawImage(sadSprite, x, y)
canvasLeft.DrawImage(hiddenImage, 0, 0)
x = x + xSpeed
y = y + ySpeed
If x <= 0 Then
xSpeed = randomGenerator.Next(1, 5)
ElseIf x >= picLeft.Width - sadSprite.Width Then
xSpeed = randomGenerator.Next(-5, 1)
ElseIf y <= 0 Then
ySpeed = randomGenerator.Next(1, 5)
ElseIf y >= picLeft.Height - sadSprite.Height Then
ySpeed = randomGenerator.Next(-5, 1)
End If
Thread.Sleep(30)
Application.DoEvents()
Loop Until userQuits
End If
End Sub
'subroutine to transform left polygon
Private Sub leftTransform(ByVal transformationCode As Integer)
'translate to computer origin
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X - gridCenterX
leftPolygon(i).Y = leftPolygon(i).Y - gridCenterY
Next i
' decide which transformation to do
If transformationCode = 1 Then
'do translation
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X + translateX
leftPolygon(i).Y = leftPolygon(i).Y + translateY
Next i
ElseIf transformationCode = 2 Then
'do reflection over x-axis
For i = 0 To 3
leftPolygon(i).Y = -1 * leftPolygon(i).Y
Next i
ElseIf transformationCode = 3 Then
'do reflection over y-axis
For i = 0 To 3
leftPolygon(i).X = -1 * leftPolygon(i).X
Next i
ElseIf transformationCode = 4 Then
'do reflection over y = x
' opposite, since computer does +y as down
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = -1 * temporaryY
leftPolygon(i).Y = -1 * temporaryX
Next i
ElseIf transformationCode = 5 Then
'do reflection over y = -x
' opposite, since computer does +y as down
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = temporaryY
leftPolygon(i).Y = temporaryX
Next i
ElseIf transformationCode = 6 Then
'do rotation 90 CW
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = -1 * temporaryY
leftPolygon(i).Y = temporaryX
Next i
ElseIf transformationCode = 7 Then
'do rotation 180
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = -1 * temporaryX
leftPolygon(i).Y = -1 * temporaryY
Next i
ElseIf transformationCode = 8 Then
'do rotation 90 CCW
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = temporaryY
leftPolygon(i).Y = -1 * temporaryX
Next i
ElseIf transformationCode = 9 Then
'do size transformation
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X * MagnitudeX
leftPolygon(i).Y = leftPolygon(i).Y * MagnitudeY
Next i
End If
'translate from computer origin
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X + gridCenterX
leftPolygon(i).Y = leftPolygon(i).Y + gridCenterY
Next i
End Sub
'subroutine to do second transformation of left polygon
Private Sub leftTransform2(ByVal transformationCode As Integer)
'translate to computer origin
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X - gridCenterX
leftPolygon(i).Y = leftPolygon(i).Y - gridCenterY
Next i
' decide which transformation to do
If transformationCode = 1 Then
'do translation
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X + translateX2
leftPolygon(i).Y = leftPolygon(i).Y + translateY2
Next i
ElseIf transformationCode = 2 Then
'do reflection over x-axis
For i = 0 To 3
leftPolygon(i).Y = -1 * leftPolygon(i).Y
Next i
ElseIf transformationCode = 3 Then
'do reflection over y-axis
For i = 0 To 3
leftPolygon(i).X = -1 * leftPolygon(i).X
Next i
ElseIf transformationCode = 4 Then
'do reflection over y = x
' opposite, since computer does +y as down
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = -1 * temporaryY
leftPolygon(i).Y = -1 * temporaryX
Next i
ElseIf transformationCode = 5 Then
'do reflection over y = -x
' opposite, since computer does +y as down
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = temporaryY
leftPolygon(i).Y = temporaryX
Next i
ElseIf transformationCode = 6 Then
'do rotation 90 CW
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = -1 * temporaryY
leftPolygon(i).Y = temporaryX
Next i
ElseIf transformationCode = 7 Then
'do rotation 180
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = -1 * temporaryX
leftPolygon(i).Y = -1 * temporaryY
Next i
ElseIf transformationCode = 8 Then
'do rotation 90 CCW
For i = 0 To 3
temporaryX = leftPolygon(i).X
temporaryY = leftPolygon(i).Y
leftPolygon(i).X = temporaryY
leftPolygon(i).Y = -1 * temporaryX
Next i
ElseIf transformationCode = 9 Then
'do size transformation
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X * MagnitudeX2
leftPolygon(i).Y = leftPolygon(i).Y * MagnitudeY2
Next i
End If
'translate from computer origin
For i = 0 To 3
leftPolygon(i).X = leftPolygon(i).X + gridCenterX
leftPolygon(i).Y = leftPolygon(i).Y + gridCenterY
Next i
End Sub
'subroutine to transform right polygon
Private Sub rightTransform(ByVal transformationCode As Integer)
'translate to computer origin
For i = 0 To 3
rightPolygon(i).X = rightPolygon(i).X - gridCenterX
rightPolygon(i).Y = rightPolygon(i).Y - gridCenterY
Next i
' decide which transformation to do
If transformationCode = 1 Then
'do translation
For i = 0 To 3
rightPolygon(i).X = rightPolygon(i).X + translateX
rightPolygon(i).Y = rightPolygon(i).Y + translateY
Next i
ElseIf transformationCode = 2 Then
'do reflection over x-axis
For i = 0 To 3
rightPolygon(i).Y = -1 * rightPolygon(i).Y
Next i
ElseIf transformationCode = 3 Then
'do reflection over y-axis
For i = 0 To 3
rightPolygon(i).X = -1 * rightPolygon(i).X
Next i
ElseIf transformationCode = 4 Then
'do reflection over y = x
' opposite, since computer does +y as down
For i = 0 To 3
temporaryX = rightPolygon(i).X
temporaryY = rightPolygon(i).Y
rightPolygon(i).X = -1 * temporaryY
rightPolygon(i).Y = -1 * temporaryX
Next i
ElseIf transformationCode = 5 Then
'do reflection over y = -x
' opposite, since computer does +y as down
For i = 0 To 3
temporaryX = rightPolygon(i).X
temporaryY = rightPolygon(i).Y
rightPolygon(i).X = temporaryY
rightPolygon(i).Y = temporaryX
Next i
ElseIf transformationCode = 6 Then
'do rotation 90 CW
For i = 0 To 3
temporaryX = rightPolygon(i).X
temporaryY = rightPolygon(i).Y
rightPolygon(i).X = -1 * temporaryY
rightPolygon(i).Y = temporaryX
Next i
ElseIf transformationCode = 7 Then
'do rotation 180
For i = 0 To 3
temporaryX = rightPolygon(i).X
temporaryY = rightPolygon(i).Y
rightPolygon(i).X = -1 * temporaryX
rightPolygon(i).Y = -1 * temporaryY
Next i
ElseIf transformationCode = 8 Then
'do rotation 90 CCW
For i = 0 To 3
temporaryX = rightPolygon(i).X
temporaryY = rightPolygon(i).Y
rightPolygon(i).X = temporaryY
rightPolygon(i).Y = -1 * temporaryX
Next i
ElseIf transformationCode = 9 Then
'do size transformation
For i = 0 To 3
rightPolygon(i).X = rightPolygon(i).X * MagnitudeX
rightPolygon(i).Y = rightPolygon(i).Y * MagnitudeY
Next i
End If
'translate from computer origin
For i = 0 To 3
rightPolygon(i).X = rightPolygon(i).X + gridCenterX
rightPolygon(i).Y = rightPolygon(i).Y + gridCenterY
Next i
End Sub
End Class
"Form 2":
Public Class Form2
'no code really happens here.
End Class
"Form 3":
Public Class Form3
'only need to re-open the score window when its closed
Private Sub Form3_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Form1.scoreForm = New Form3
Form1.scoreForm.Show()
Form1.scoreForm.playedLabel1.Text = Form1.level1Played
Form1.scoreForm.playedLabel2.Text = Form1.level2Played
Form1.scoreForm.playedLabel3.Text = Form1.level3Played
Form1.scoreForm.playedLabel4.Text = Form1.level4Played
Form1.scoreForm.playedLabel5.Text = Form1.level5Played
Form1.scoreForm.correctLabel1.Text = Form1.level1Correct
Form1.scoreForm.correctLabel2.Text = Form1.level2Correct
Form1.scoreForm.correctLabel3.Text = Form1.level3Correct
Form1.scoreForm.correctLabel4.Text = Form1.level4Correct
Form1.scoreForm.correctLabel5.Text = Form1.level5Correct
Form1.scoreForm.totalScoreLabel.Text = Form1.totalScore
End Sub
End Class