Kevin Bishop | Powerpoint Programming

Powerpoint Programming


  • 17 Jul


  • KevinBish

Download the PDF file .

VBA Code:

__________________________________________________________________________

Private Declare PtrSafe Function GetAsyncKeyState Lib “user32.dll” (ByVal KeyCode As Long) As Integer

Private Declare PtrSafe Function SetTimer Lib “user32” ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Private Declare PtrSafe Function KillTimer Lib “user32” ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long

 

Public boolFlag As Boolean ‘Used to control game loop
Dim intScore As Integer

 

‘Name: StartGame
‘Description: Changes Slide and Sets Player X, Y Coordinates, and Movement
‘Input: None
‘Output: None
‘Last edited: Date: March 26th 2011, By Kevin
Public Sub StartGame()
ActivePresentation.SlideShowWindow.View.Next
Call SetPlayer_X_Y(13, 336)
Call Movement_Collision
End Sub

‘Name: GameSeq
‘Description: Coordinates the movement of the Mini-Bosses and JumpBand
‘Input: None
‘Output: None
‘Last edited: Date: March 26th 2011, By Kevin
Public Sub GameSeq()

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Jumpup”).IncrementLeft (-10)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss1”).IncrementLeft (-10)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow1”).IncrementLeft (-10)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss2”).IncrementLeft (-10)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow2”).IncrementLeft (-10)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss3”).IncrementLeft (-10)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow3”).IncrementLeft (-10)
End Sub

 
‘Name: Movement_Collision
‘Description: Controls Player / Game Enviroment Movement
‘Input: None
‘Output: None
‘Last edited: Date: March 26th 2011, By Kevin

Public Sub Movement_Collision()
Dim PauseTime, Start
Dim ShiftKeyState
PauseTime = 10
Start = Timer
boolFlag = True

‘Needs a sleep timer / kill timer to let animtions run
While (boolFlag)

Call GameSeq

‘Input: Key Press Up

ShiftKeyState = GetAsyncKeyState(vbKeyW)
If ShiftKeyState And &H8000 Then

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”).IncrementTop (-10)

End If

‘Input: Key Press Down

ShiftKeyState = GetAsyncKeyState(vbKeyS)
If ShiftKeyState And &H8000 Then

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”).IncrementTop (10)
End If

‘Input: Key Press Left

ShiftKeyState = GetAsyncKeyState(vbKeyA)
If ShiftKeyState And &H8000 Then

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”).IncrementLeft (-20)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Background”).IncrementLeft (20)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“boundary”).IncrementLeft (20)

End If

‘Input: Key Press Right

ShiftKeyState = GetAsyncKeyState(vbKeyD)
If ShiftKeyState And &H8000 Then

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”).IncrementLeft (20)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Background”).IncrementLeft (-20)
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“boundary”).IncrementLeft (-20)
If (detection(ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”), ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss2”)) = True) Then

intScore = intScore + 1
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Score”).TextFrame.TextRange.Text = intScore

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss2”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow2”).Left = ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss2”).Left
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow2”).Top = ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss2”).Top
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow2”).Visible = True
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“stilt1”).Visible = True

End If

If (detection(ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”), ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss1”)) = True) Then

intScore = intScore + 1
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Score”).TextFrame.TextRange.Text = intScore

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss1”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow1”).Left = ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss1”).Left
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow1”).Top = ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss1”).Top
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow1”).Visible = True
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“stilt2”).Visible = True
End If

 

If (detection(ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”), ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss3”)) = True) Then

intScore = intScore + 1
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Score”).TextFrame.TextRange.Text = intScore

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss3”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow3”).Left = ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss3”).Left
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow3”).Top = ActivePresentation.SlideShowWindow.View.Slide.Shapes(“Miniboss3”).Top
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“pow3”).Visible = True
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“stilt3”).Visible = True

End If

If (detection(ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”), ActivePresentation.SlideShowWindow.View.Slide.Shapes(“boundary”)) = True) Then

ActivePresentation.SlideShowWindow.View.Next

End If

End If

DoEvents
Wend

End Sub

‘Name: Stop_Movement_Collision
‘Description: Stop Controls Player / Game Enviroment Movement
‘Input: None
‘Output: None
‘Last edited: Date: March 26th 2011, By Kevin
Public Sub Stop_Movement_Collision()

boolFlag = False

End Sub

‘Name: SetPlayer_X_Y
‘Description: Sets Player Position
‘Input: None
‘Output: None
‘Last edited: Date: March 26th 2011, By Kevin

Public Sub SetPlayer_X_Y(ByVal intX As Integer, ByVal intY As Integer)

ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”).Left = intX
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“hero”).Top = intY

End Sub

‘Name: GotoNextSlide
‘Description: Goto next powerpoint slide
‘Input: None
‘Output: None
‘Last edited: Date: March 26th 2011, By Kevin

Private Sub GotoNextSlide()
Application.SlideShowWindows(1).View.Next
End Sub
‘Name: Detection
‘Description: Object Collision Detection
‘Input: Object/Shapes
‘Output: Object Hit or Miss
‘Last edited: Date: March 26th 2011, By Kevin

Public Function detection(objShapeI As Shape, objShapeII As Shape) As Boolean
If objShapeI.Left < objShapeII.Left + objShapeII.Width And objShapeII.Left < objShapeI.Left + objShapeII.Width Then
detection = False

If objShapeI.Top < objShapeII.Top + objShapeII.Height And objShapeII.Top < objShapeI.Top + objShapeII.Height Then
detection = True

End If
End If

End Function

‘Name: SetShapeCoord
‘Description: Moves passed in shape to specific coordinates
‘Input: intended X and Y coordinates for shape
‘Output: Shape moved to given coordinates
‘Last edited: Date: March 26th 2011, By Noel

Private Sub SetShapeCoord(myShape, ByVal intXcoord As Integer, ByVal intYcoord As Integer)
myShape.Top = intYcoord
myShape.Left = intXcoord

End Sub
Sub Heart()

If heart_count = 4 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart4”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart3”).Visible = True
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart2”).Visible = True
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart1”).Visible = True

‘ heart_count = heart_count – 1

ElseIf heart_count = 3 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart4”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart3”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart2”).Visible = True
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart1”).Visible = True
‘heart_count = heart_count – 1

ElseIf heart_count = 2 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart4”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart3”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart2”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart1”).Visible = True
‘heart_count = heart_count – 1

ElseIf heart_count = 1 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart4”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart3”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart2”).Visible = False
ActivePresentation.SlideShowWindow.View.Slide.Shapes(“heart1”).Visible = False
‘heart_count = heart_count – 1

End If
heart_count = heart_count – 1
End Sub