
FreeBASIC's Official Forums
|
| View previous topic :: View next topic |
| Author |
Message |
|
|
Posted: Jan 26, 2006 2:56 Post subject: Inspired by the Falling Sand Game! |
|
|
I wont tell ya anything, see if you can figure out how to reach the goals!
| Code:
|
' Flow Control' Mambazo@gmail.com' Ideas:'' Warp hole. Sand goes in one node, comes out the other ;)'' More Sand TypesOption Explicit#DEFINE ScrW 800#DEFINE ScrH 600Const VOID = 0Const WATER = 1Const WATERRIGHT = 2Const WATERLEFT = 3Const SAND = 4Const SANDRIGHT = 5Const SANDLEFT = 6Const WALL = 7Const CURSOR = 10Const LIGHTBOX = 11Const DARKBOX = 12Const LIGHTKILLER = 13Const DARKKILLER = 14Const B_Size = ScrW * ScrH SCREENRES ScrW, ScrH, 8,3 ',&h1Palette 1, 255, 255, 255Palette 2, 255, 255, 255Palette 3, 255, 255, 255Palette 4, 100, 100, 100Palette 5, 100, 100, 100Palette 6, 100, 100, 100Palette 10, 255, 0, 0Palette 7, 155, 100, 40Palette 11, 255, 255, 255Palette 12, 100, 100, 100Palette 13, 70, 70, 70Palette 14, 205, 205, 205Randomize TimerDim As String in Dim As Integer i, j, Boff, MouseX, MouseY, Buttons, _ Wheel, TotalWater, ButtonHold, _ MouseXo, MouseYo, PenSize, Wheelo, _ ScoreLight, GoalLight, ScoreDark, GoalDark, RandX, RandY, _ Grains, GrainToggle, seconds Dim As Byte pixel Dim As Double t, Rand, tsec start: ClsBoff = 1SETMOUSE ,, 0Print "Press any key to begin!"SleepSCREENSET 2, 1ClsDim Buffer As Byte PtrBuffer = SCREENPTR Grains = 3000PenSize = 2ScoreDark = 0ScoreLight = 0GoalLight = 500GoalDark = 500' Fixed LevelFor i = 0 To 6 RandX = Int(Rnd* (ScrW- 20)) RandY = Int(Rnd* (ScrH- 180))+ 80 Line (RandX,RandY )- (RandX+ 20,RandY+ 20),DARKKILLER,BF RandX = Int(Rnd* (ScrW- 20)) RandY = Int(Rnd* (ScrH- 180))+ 80 Line (RandX,RandY )- (RandX+ 20,RandY+ 20),LIGHTKILLER,BF Next i tsec = Timerseconds = 1Do Boff = (Boff + 1) Mod 2 If Timer > tsec + 1 Then seconds += 1: tsec = Timer t = Timer in = Inkey$ MouseXo = MouseX: MouseYo = MouseY: Wheelo = Wheel GETMOUSE MouseX, MouseY, Wheel, Buttons SCREENLOCK If Grains > 0 Then If GrainToggle = 0 Then GrainToggle = 1 Else GrainToggle = 0 If GrainToggle = 0 Then Pset (ScrW/ 2+ Int(Rnd* 8), 8),WATER If GrainToggle = 1 Then Pset (ScrW/ 2+ Int(Rnd* 8), 8),SAND Grains -= 1 End If If Buttons And MouseX > - 1 Then If (Buttons And 4) And ButtonHold = 0 Then ButtonHold = 1 PenSize = (PenSize * 2) Mod 32 If PenSize < 2 Then PenSize = 2 End If If (Buttons ) And ButtonHold = 0 Then ButtonHold = 1 MouseXo = MouseX: MouseYo = MouseY End If If (buttons And 2) And ButtonHold = 1 Then For i = 0 To PenSize For j = 0 To PenSize Line (MouseXo+i,MouseYo+j )- (MouseX+i,MouseY+j ), 0 Next j Next i End If If (buttons And 1) And ButtonHold = 1 Then For i = 0 To PenSize For j = 0 To PenSize Line (MouseXo+i,MouseYo+j )- (MouseX+i,MouseY+j ), 7 Next j Next i End If Else ButtonHold = 0 End If ' GOALS! Circle (20,ScrH - 20), 10,LIGHTBOX,,,,F Circle (ScrW- 20,ScrH - 20), 10,DARKBOX,,,,F For i = (B_Size - Boff - 1) To 1 Step - 2 pixel = Buffer [i ] If Buffer [i+ScrW ] = DARKBOX And (pixel = SAND Or pixel = SANDRIGHT Or pixel = SANDLEFT )Then ScoreDark += 1 Buffer [i ] = VOID End If If Buffer [i+ScrW ] = LIGHTBOX And (pixel = WATER Or pixel = WATERRIGHT Or pixel = WATERLEFT )Then ScoreLight += 1 Buffer [i ] = VOID End If If Buffer [i+ScrW ] = LIGHTBOX And (pixel = SAND Or pixel = SANDRIGHT Or pixel = SANDLEFT )Then ScoreLight -= 10 Buffer [i ] = VOID End If If Buffer [i+ScrW ] = DARKBOX And (pixel = WATER Or pixel = WATERRIGHT Or pixel = WATERLEFT )Then ScoreDark -= 10 Buffer [i ] = VOID End If If Buffer [i+ScrW ] = DARKKILLER And (pixel = SAND Or pixel = SANDRIGHT Or pixel = SANDLEFT )Then Buffer [i ] = VOID Buffer [i+ScrW ] = VOID End If If Buffer [i+ScrW ] = LIGHTKILLER And (pixel = WATER Or pixel = WATERRIGHT Or pixel = WATERLEFT )Then Buffer [i ] = VOID Buffer [i+ScrW ] = VOID End If pixel = Buffer [i ] ' Handle Water If pixel = WATER Then If i < (B_Size - ScrW ) Then If Buffer [i+ScrW ] = VOID And Buffer [i+ 1] = VOID And Buffer [i- 1] = VOID Then Buffer [i ] = VOID Buffer [i+ScrW ] = WATER Else Rand = Rnd If Rand < . 5 Then Buffer [i ] = WATERRIGHT If Rand > . 5 Then Buffer [i ] = WATERLEFT End If End If End If If pixel = WATERLEFT Then If i < (B_Size - ScrW ) Then If Buffer [i+ScrW ] = VOID Then Buffer [i ] = VOID Rand = Rnd If Rand <. 5 Then Buffer [i+ScrW ] = WATERRIGHT If Rand >. 5 Then Buffer [i+ScrW ] = WATER Else If (Buffer [i- 1] = VOID ) Then Buffer [i ] = VOID Buffer [i- 1] = WATERLEFT Else Buffer [i ] = WATERRIGHT End If End If End If End If If pixel = WATERRIGHT Then If i < (B_Size - ScrW ) Then If Buffer [i+ScrW ] = VOID Then Buffer [i ] = VOID Rand = Rnd If Rand <. 5 Then Buffer [i+ScrW ] = WATERLEFT If Rand >. 5 Then Buffer [i+ScrW ] = WATER Else If (Buffer [i+ 1] = VOID ) Then Buffer [i ] = VOID Buffer [i+ 1] = WATERRIGHT Else Buffer [i ] = WATERLEFT End If End If End If End If ' Handle Sand If pixel = SAND Then If i < (B_Size - ScrW ) Then If Buffer [i+ScrW ] = VOID And Buffer [i+ 1] = VOID And Buffer [i- 1] = VOID Then Buffer [i ] = VOID Buffer [i+ScrW ] = SAND Else Rand = Rnd If Rand < . 5 Then Buffer [i ] = SANDRIGHT If Rand > . 5 Then Buffer [i ] = SANDLEFT End If End If End If If pixel = SANDLEFT Then If i < (B_Size - ScrW ) Then If Buffer [i+ScrW ] = VOID Then Buffer [i ] = VOID Rand = Rnd If Rand <. 5 Then Buffer [i+ScrW ] = SANDRIGHT If Rand >. 5 Then Buffer [i+ScrW ] = SAND Else If (Buffer [i- 1] = VOID ) Then Buffer [i ] = VOID Buffer [i- 1] = SANDLEFT Else Buffer [i ] = SANDRIGHT End If End If End If End If If pixel = SANDRIGHT Then If i < (B_Size - ScrW ) Then If Buffer [i+ScrW ] = VOID Then Buffer [i ] = VOID Rand = Rnd If Rand <. 5 Then Buffer [i+ScrW ] = SANDLEFT If Rand >. 5 Then Buffer [i+ScrW ] = SAND Else If (Buffer [i+ 1] = VOID ) Then Buffer [i ] = VOID Buffer [i+ 1] = SANDRIGHT Else Buffer [i ] = SANDLEFT End If End If End If End If Next i SCREENCOPY 2, 1 SCREENSET 1, 2 Line (MouseX,MouseY )- (MouseX+PenSize,MouseY+PenSize ), 10,B Locate 1, 1: Print "Seconds Elapsed: "; seconds Locate 2, 1: Print "Pen Size:"; PenSize Locate 3, 1: Print "Light Sand:"; ScoreLight; " /"; GoalLight Locate 4, 1: Print "Dark Sand:"; ScoreDark; " /"; GoalDark SCREENSET 2, 1 SCREENUNLOCK While Timer < t + 0. 005: Sleep 1: WendLoop Until in = Chr$ (27) Or (ScoreLight >= GoalLight And ScoreDark >= GoalDark )SCREENSET 1, 1Color 15: Print "You scored:"; (ScoreLight+ScoreDark )- (seconds )Print "Play Again? Y/N"Doin = Inkey$ If in = "y" Then Goto start Loop Until in= "n"SETMOUSE ,, 1 |
Last edited by mambazo on Jan 27, 2006 12:57; edited 2 times in total |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 26, 2006 3:32 Post subject: |
|
|
| Very very cool. I didn't beat it but I figured out how to score properly. I just don't have the patience to play through a whole game at the moment. ;-) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 26, 2006 16:05 Post subject: |
|
|
| I'm guessing it's something to do with sending the dots over the blocks to get rid of the different colors and sending them to there right color circle, but I never played long enough to figure that out and try it, I will tonight though, and it's great by the way, a stroke of genius. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 26, 2006 17:21 Post subject: |
|
|
| Sshhh... no revealing game secrets. ^_^ |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 26, 2006 18:07 Post subject: |
|
|
:p
I'll be using this as a prototype for a proper game. I've got a few ideas for it already, but I won't be working on this until Arena - To The Death is complete. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 26, 2006 18:26 Post subject: |
|
|
| hehe Good enough for me. ^_^ |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 0:57 Post subject: |
|
|
| i got -1500 points and pushed escape.. did i win? :P |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 1:18 Post subject: |
|
|
| lol, t'was a valliant effort i'm sure ;) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 2:16 Post subject: |
|
|
| i got 491 but i cant prove it since the screenshot didn't work x( |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 3:26 Post subject: |
|
|
| Deleter wrote: | | i got 491 but i cant prove it since the screenshot didn't work x( |
alt + enter then print screen... |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 3:50 Post subject: |
|
|
Could you make it run in a window by default please? I prefer it when programs don't change my screen resolution.
(Note, if you do this, you'll have to add in a check to make sure it only draws lines when the mouse is within the window. Otherwise, if you move the mouse out of the window while holding the button, it will draw a line to the top left corner of the screen. And make the player curse.) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 12:58 Post subject: |
|
|
| Code updated, just for you counting_pine, I added 1 line, gosh that was tricky ;) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 13:49 Post subject: |
|
|
| Hiscore: 840 Yay! |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 13:54 Post subject: |
|
|
| Wow, even I didn't get that much!! perhaps take a screenshot of your highscore next time! Would be fun to make an online high score somewhow. ill add that to the project notes ;) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 27, 2006 14:02 Post subject: |
|
|
New high score chaps! ;)
 |
| |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|