Ooops
November 25, 2020, 06:09:32 AM

Author Topic: [bb] Waggler by EOF [ 1+ years ago ]  (Read 557 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Waggler by EOF [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Waggler
Author : EOF
Posted : 1+ years ago

Description : *Updated - now operates as a function.

Remember those oldskool games such as Decathlon and Hypersports where you clock the joystick as fast as possible to gain speed?
Well, heres a very simple bit of code for implementing that in a game.


Code :
Code: BlitzBasic
  1. ;; Waggler - by Syntax_Error
  2. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3.  
  4. ; A little bit of code for joystick/keyboard waggling
  5. ; games like the classic Decathlon & Hypersports
  6.  
  7.  
  8. ; #######################
  9. Dim wkey(1) : wkey(0)=42 : wkey(1)=54   ; left/right SHIFT keys (scancodes)
  10. Global WaggleToggle                     ; waggle toggle flag
  11.  
  12. ; waggle function
  13. Function GetWaggleSpeed#(speed#,inputmethod=0)
  14.         If inputmethod=1
  15.                 If JoyXDir()=WaggleToggle*2-1
  16.                         WaggleToggle=Not WaggleToggle
  17.                         speed=speed+5.7
  18.                 EndIf
  19.         Else
  20.                 If KeyHit(wkey(WaggleToggle))
  21.                         WaggleToggle=Not WaggleToggle
  22.                         speed=speed+7.9
  23.                 EndIf
  24.         EndIf
  25.         If speed>0.89 Then speed=speed-0.89
  26.         If speed>100 Then speed=100
  27.         Return speed
  28. End Function
  29. ; #######################
  30.  
  31.  
  32. ; example code
  33. Graphics 640,480
  34. SetBuffer BackBuffer()
  35.  
  36. wagglespeed#=75
  37.  
  38. While Not KeyHit(1)
  39.         Cls
  40.         wagglespeed#=GetWaggleSpeed(wagglespeed#,method)
  41.         ; simple bar
  42.         Color 40,40,40 : Rect 100,100,201,16
  43.         Color 20,200,40 : Rect 101,101,wagglespeed*2,14
  44.         Text 125,128,"Speed:"+Int(wagglespeed)
  45.         ;
  46.         If KeyHit(57) method=Not method
  47.         Color 100,200,200
  48.         Text 100,160,"Input Method: "+Mid$("KEYBOARDJOYSTICK",method*8+1,8)
  49.         Text 140,180,"(Press SPACEBAR to toggle)"
  50.         Flip
  51. Wend
  52.  
  53. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal