home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1995-09-14 | 5.1 KB | 259 lines |
- '
- ' MOMENTUMBALL
- '
- ' (c) Richard Williams
- '
- ' Revision Date : 14/9/95
- '
- ' Demonstration of momentum and hardware scrolling
- '
- ' The game itself is simple and a little fun !
- ' All you have to do is move the ball (blue) across the screen and
- ' hit the opposite wall (on the right) and come back and hit
- ' the wall you started at ! Got it ? Oh by the way, avoid
- ' the computer (red) ball.
- '
- ' Initialise Screen (open big bitmap)
- Screen Open 0,1000,200,4,Lowres
- Screen Display 0,128,50,,
- Paper 0 : Pen 1 : Flash Off : Curs Off : Hide : Cls
- Palette 0,$FFF,$F00,$F
- Cls
- ' Generate and grab sprites from screen
- Screen Hide
- Ink 1
- Circle 100,100,8
- Ink 3
- Paint 100,100,1
- Get Bob 1,92,92 To 109,109
- Cls
- Ink 1
- Circle 100,100,8
- Ink 2
- Paint 100,100,1
- Get Bob 2,92,92 To 109,109
- Cls
- Screen Show
- ' Initialise game time variables
- Dim LAG(15),LSL(15)
- Restore LEVEL_DATA
- For N=1 To 15
- Read LAG(N),LSL(N)
- Next
- L=0
- SC=0
- DEAD=False
- Set Line %1010101010101010
- ' Main game loop
- Repeat
- Cls
- Colour 0,0
- Pen 1
- Inc L
- Print "LEVEL ";L
- Wait 100
- Ink 3
- Cls
- For N=0 To 964 Step 16
- Draw N,0 To N,200
- Next
- For N=0 To 200 Step 16
- Draw 0,N To 960,N
- Next
- Ink 2
- Box 0,0 To 960,199
- Box 1,1 To 959,198
- ' Initialise level time variables
- A=0 : B=0 : C=50 : D=50 : DD=0 : CC=0
- E=Rnd(500)+400 : F=Rnd(100)+50 : EE=0 : FF=0
- AG=LAG(L) : SL=LSL(L)
- HIT_FAR_SIDE=False
- T=1000
- CREG0=0
- LEVEL_FINISHED=False
- Repeat
- ' Control timer and screen getting brighter bit
- T=T-1
- If T<0
- If T mod 8=0
- Add CREG0,$111
- If CREG0=$FFF
- DEAD=True
- End If
- Colour 0,CREG0
- End If
- End If
- ' Set the screen offset (hardware scroll)
- Screen Offset 0,A,B
- '
- ' Players Bob Control
- '
- ' Interpret users controls
- J=Joy(1)
- ' Add to momentum value
- If J and 1
- DD=DD-1
- End If
- If J and 2
- DD=DD+1
- End If
- If J and 4
- CC=CC-1
- End If
- If J and 8
- CC=CC+1
- End If
- ' Check momentum does not exceed a certain value
- ' ie this is your maximum speed in pixels
- If DD>4
- DD=4
- End If
- If DD<-4
- DD=-4
- End If
- If CC>4
- CC=4
- End If
- If CC<-4
- CC=-4
- End If
- ' Move players sprite - Add the balls momentum values
- C=C+CC
- D=D+DD
- ' Only scroll if balls x coordinate is inside these limits
- If(C>159) or(C<806)
- A=A+CC
- End If
- ' Check if far side is hit - Reverese momentum makes ball bounce
- If(C>940)
- CC=-4
- If Not(HIT_FAR_SIDE)
- Bell
- HIT_FAR_SIDE=True
- End If
- End If
- ' Check if player has reached home again (if not - just bounce)
- If(C<0)
- CC=4
- ' Check for end of level
- If HIT_FAR_SIDE
- For N=1 To 90 Step 4
- Bell N
- Wait 1
- Next
- SC=SC+(T*3)
- LEVEL_FINISHED=True
- End If
- End If
- ' Set screen offset when ball is outside scrolling range
- If C<160
- A=0
- End If
- If C>805
- A=650
- End If
- ' Control y direction bounce
- If(D<0)
- DD=4
- End If
- If(D>182)
- DD=-4
- End If
- Bob 1,C,D,1
- '
- ' Computer Bob Control
- '
- ' Control momentum dependent on players ball position
- If C<E
- Dec EE
- End If
- If C>E
- Inc EE
- End If
- If D>F
- Inc FF
- End If
- If D<F
- Dec FF
- End If
- ' Check for balls maximum momentum value
- If EE>AG
- EE=AG
- End If
- If EE<-AG
- EE=-AG
- End If
- If FF>AG
- FF=AG
- End If
- If FF<-AG
- FF=-AG
- End If
- ' Add momentum to computer ball (SL=slow down effect)
- E=E+(EE/SL)
- F=F+(FF/SL)
- ' If ball hits wall - bounce
- If E<0 or E>964
- EE=-EE
- End If
- If F<0 or F>182
- FF=-FF
- End If
- Bob 2,E,F,2
- Wait Vbl
- ' Detect player/computer collision
- If Bob Col(1)=-1
- DEAD=True
- End If
- Until LEVEL_FINISHED or DEAD
- If LEVEL_FINISHED and L=15
- DEAD=True
- End If
- Until DEAD
- ' Reset screen
- Screen Offset 0,0,0
- Colour 0,0
- Cls
- Boom
- Restore MESSAGES
- For N=1 To L
- Read A$
- Next
- Print A$
- Print "Score=";SC
- If L=15
- Print "You have defeated this game !"
- End If
- End
- LEVEL_DATA:
- Data 12,6
- Data 18,6
- Data 24,6
- Data 30,6
- Data 36,6
- Data 15,5
- Data 20,5
- Data 25,5
- Data 30,5
- Data 16,4
- Data 20,4
- Data 24,4
- Data 12,3
- Data 18,3
- Data 16,2
- MESSAGES:
- Data "Oh dear, get a life..."
- Data "A feeble effort..."
- Data "Pretty rubbish..."
- Data "Hmmm, more practice, a lot more..."
- Data "Well, getting there..."
- Data "Reasonable..."
- Data "Ok, not bad..."
- Data "Smart Arse..."
- Data "Steady on..."
- Data "Wow, not bad..."
- Data "WHAT! pretty damn good..."
- Data "Thats a hard act to follow, git..."
- Data "You are my mentor..."
- Data "You are a demi-god..."
- Data "You are the UNIVERSE!"