# HG changeset patch # User nemo # Date 1292995063 18000 # Node ID 445d382cd401e622681268060641fbddad791a95 # Parent e78287f800744002280f5b35cf2a421d0bed8dd6 A very very basic snow implementation diff -r e78287f80074 -r 445d382cd401 hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/GSHandlers.inc Wed Dec 22 00:17:43 2010 -0500 @@ -558,6 +558,97 @@ end end; +procedure doStepSnowflake(Gear: PGear); +var xx, yy, px, py: LongInt; + move: Boolean; + s: PSDL_Surface; + p: PLongwordArray; +begin +if GameTicks and $7 = 0 then + begin + with Gear^ do + begin + X:= X + cWindSpeed * 1600 + dX; + Y:= Y + dY + cGravity * vobFallSpeed * 8; // using same value as flakes to try and get similar results + xx:= hwRound(X); + yy:= hwRound(Y); + if vobVelocity <> 0 then + begin + DirAngle := DirAngle + (Angle / 12500000); + if DirAngle < 0 then DirAngle := DirAngle + 360 + else if 360 < DirAngle then DirAngle := DirAngle - 360; + end; + + inc(Health, 8); + if Health > vobFrameTicks then + begin + dec(Health, vobFrameTicks); + inc(Timer); + if Timer = vobFramesCount then Timer:= 0 + end; + + move:= false; + // move back to cloud layer + if yy > cWaterLine then move:= true + else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] > 255) then + begin + // we've collided with land. draw some stuff and get back into the clouds + move:= true; +////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// + Land[yy, xx]:= Land[yy, xx] or lfBasic; + if yy > 1 then + begin + Land[yy-1, xx]:= Land[yy-1, xx] or lfBasic; + if (cWindSpeed * 1600 + dX < _0) and (xx > 1) then + begin + Land[yy-1, xx-1]:= Land[yy-1, xx-1] or lfBasic; + Land[yy, xx-1]:= Land[yy, xx-1] or lfBasic + end + else if xx < LAND_WIDTH then + begin + Land[yy-1, xx+1]:= Land[yy-1, xx+1] or lfBasic; + Land[yy, xx+1]:= Land[yy, xx+1] or lfBasic + end + end; + dec(yy,4); + dec(xx,2); + if (((cReducedQuality and rqBlurryLand) = 0) and + (xx >= 0) and (xx < LAND_WIDTH-2) and (yy >= 0) and (yy < LAND_HEIGHT)) or + (((cReducedQuality and rqBlurryLand) <> 0) and + (xx >= 0) and (xx < (LAND_WIDTH div 2)-2) and (yy >= 0) and (yy < LAND_HEIGHT div 2)) then + begin + s:= SpritesData[sprSnow].Surface; + p:= s^.pixels; + + for py:= 0 to Pred(s^.h) do + begin + for px:= 0 to Pred(s^.w) do + begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin + if LandPixels[yy + py, xx + py] = 0 then + LandPixels[yy + py, xx + px]:= p^[px]; + end + else + if LandPixels[(yy + py) div 2, (xx + px) div 2] = 0 then + LandPixels[(yy + py) div 2, (xx + px) div 2]:= p^[px]; + + end; + p:= @(p^[s^.pitch shr 2]) + end; + UpdateLandTexture(xx, 4, yy, 4) + end +////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// + end; + if move then + begin + X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512); + Y:= int2hwFloat(1000+(GetRandom(25)-50)) + end + end + end +end; + //////////////////////////////////////////////////////////////////////////////// procedure doStepGrave(Gear: PGear); begin diff -r e78287f80074 -r 445d382cd401 hedgewars/uCommandHandlers.pas --- a/hedgewars/uCommandHandlers.pas Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/uCommandHandlers.pas Wed Dec 22 00:17:43 2010 -0500 @@ -407,6 +407,7 @@ if isDeveloperMode then begin Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; +Theme:= s; InitStepsFlags:= InitStepsFlags or cifTheme end end; diff -r e78287f80074 -r 445d382cd401 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/uGears.pas Wed Dec 22 00:17:43 2010 -0500 @@ -47,7 +47,7 @@ implementation uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, - uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug; + uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture; procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward; @@ -128,7 +128,8 @@ @doStepHammerHit, @doStepResurrector, @doStepNapalmBomb, - @doStepSnowball + @doStepSnowball, + @doStepSnowflake ); procedure InsertGearToList(Gear: PGear); @@ -259,6 +260,21 @@ gear^.Friction:= _1; gear^.Density:= _0_5; end; + + gtFlake: begin + with Gear^ do + begin + DirAngle:= random * 360; + dx.isNegative:= GetRandom(2) = 0; + dx.QWordValue:= GetRandom(100000000); + dy.isNegative:= false; + dy.QWordValue:= GetRandom(70000000); + if GetRandom(2) = 0 then dx := -dx; + Health:= random(vobFrameTicks); + Timer:= random(vobFramesCount); + Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity + end + end; gtGrave: begin gear^.ImpactSound:= sndGraveImpact; gear^.nImpactSounds:= 1; @@ -1095,7 +1111,11 @@ cLaserSighting:= true; if (GameFlags and gfArtillery) <> 0 then - cArtillery:= true + cArtillery:= true; + +if (Theme = 'Snow') or (Theme = 'Hell') then + for i:= 0 to Pred(vobCount) do + AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(1024), gtFlake, 0, _0, _0, 0); end; procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); diff -r e78287f80074 -r 445d382cd401 hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/uGearsRender.pas Wed Dec 22 00:17:43 2010 -0500 @@ -1017,6 +1017,13 @@ Tint($FF, $FF, $FF, $FF); end; gtNapalmBomb: DrawRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + gtFlake: if vobVelocity = 0 then + //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer) + DrawSprite(sprFlake, x, y, Gear^.Timer) + else + //DrawRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle); + DrawRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle); + end; if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(x + 8, y + 8, Gear^.Tex); end; diff -r e78287f80074 -r 445d382cd401 hedgewars/uRenderUtils.pas --- a/hedgewars/uRenderUtils.pas Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/uRenderUtils.pas Wed Dec 22 00:17:43 2010 -0500 @@ -175,7 +175,7 @@ var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt; finalSurface, tmpsurf, rotatedEdge: PSDL_Surface; rect: TSDL_Rect; - chars: set of char = [#9,' ','.',';',':','?','!',',']; + chars: set of char = [#9,' ',';',':','?','!',',']; substr: shortstring; edge, corner, tail: TSPrite; begin @@ -353,4 +353,4 @@ SDL_FreeSurface(finalSurface); end; -end. \ No newline at end of file +end. diff -r e78287f80074 -r 445d382cd401 hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/uTypes.pas Wed Dec 22 00:17:43 2010 -0500 @@ -52,7 +52,7 @@ sprCheese, sprHandCheese, sprHandFlamethrower, sprChunk, sprNote, sprSMineOff, sprSMineOn, sprHandSMine, sprHammer, sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb, - sprBulletHit, sprSnowball, sprHandSnowball + sprBulletHit, sprSnowball, sprHandSnowball, sprSnow ); // Gears that interact with other Gears and/or Land @@ -67,7 +67,7 @@ gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives, gtBirdy, // 45 gtEgg, gtPortal, gtPiano, gtGasBomb, gtSineGunShot, gtFlamethrower, // 51 gtSMine, gtPoisonCloud, gtHammer, gtHammerHit, gtResurrector, // 56 - gtNapalmBomb, gtSnowball); // 58 + gtNapalmBomb, gtSnowball, gtFlake); // 58 // Gears that are _only_ of visual nature (e.g. background stuff, visual effects, speechbubbles, etc.) TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire, diff -r e78287f80074 -r 445d382cd401 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Wed Dec 22 04:09:56 2010 +0100 +++ b/hedgewars/uVariables.pas Wed Dec 22 00:17:43 2010 -0500 @@ -139,6 +139,8 @@ ScreenFadeValue : LongInt; ScreenFadeSpeed : LongInt; + Theme : shortstring; + {$IFDEF SDL13} SDLwindow : PSDL_Window; {$ENDIF} @@ -553,7 +555,9 @@ (FileName: 'Snowball'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil; Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprSnowball (FileName: 'amSnowball'; Path: ptCurrTheme; AltPath: ptHedgehog; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true) // sprHandSnowball + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprHandSnowball + (FileName: 'Snow'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil; + Width: 4; Height: 4; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true) // sprSnow );