More tweaks from the Rubocop overlord

This commit is contained in:
Maruno17
2021-12-19 17:28:59 +00:00
parent 33781493f4
commit 65b1a8d6c3
161 changed files with 2839 additions and 2967 deletions

View File

@@ -43,13 +43,13 @@ class TilePuzzleCursor < BitmapSprite
self.bitmap.clear
x = (Graphics.width - (@tilewidth * @boardwidth)) / 2
if @position >= @boardwidth * @boardheight
x = (x - (@tilewidth * (@boardwidth / 2).ceil)) / 2 - 10
x = ((x - (@tilewidth * (@boardwidth / 2).ceil)) / 2) - 10
if (@position % @boardwidth) >= (@boardwidth / 2).ceil
x = Graphics.width - x - @tilewidth * @boardwidth
x = Graphics.width - x - (@tilewidth * @boardwidth)
end
end
x += @tilewidth * (@position % @boardwidth)
y = (Graphics.height - (@tileheight * @boardheight)) / 2 - 32
y = ((Graphics.height - (@tileheight * @boardheight)) / 2) - 32
y += @tileheight * ((@position % (@boardwidth * @boardheight)) / @boardwidth)
self.tone = Tone.new(0, (@holding ? 64 : 0), (@holding ? 64 : 0), 0)
# Cursor
@@ -57,8 +57,8 @@ class TilePuzzleCursor < BitmapSprite
expand = (@holding) ? 0 : 4
for i in 0...4
self.bitmap.blt(
x + (i % 2) * (@tilewidth - @cursorbitmap.width / 4) + expand * (((i % 2) * 2) - 1),
y + (i / 2) * (@tileheight - @cursorbitmap.height / 2) + expand * (((i / 2) * 2) - 1),
x + ((i % 2) * (@tilewidth - (@cursorbitmap.width / 4))) + (expand * (((i % 2) * 2) - 1)),
y + ((i / 2) * (@tileheight - (@cursorbitmap.height / 2))) + (expand * (((i / 2) * 2) - 1)),
@cursorbitmap.bitmap, Rect.new((i % 2) * @cursorbitmap.width / 4,
(i / 2) * @cursorbitmap.height / 2,
@cursorbitmap.width / 4, @cursorbitmap.height / 2)
@@ -68,14 +68,14 @@ class TilePuzzleCursor < BitmapSprite
# Arrows
if @selected || @game == 3
expand = (@game == 3) ? 0 : 4
xin = [(@tilewidth - @cursorbitmap.width / 4) / 2, -expand,
@tilewidth - @cursorbitmap.width / 4 + expand, (@tilewidth - @cursorbitmap.width / 4) / 2]
yin = [@tileheight - @cursorbitmap.height / 2 + expand, (@tileheight - @cursorbitmap.height / 2) / 2,
(@tileheight - @cursorbitmap.height / 2) / 2, -expand]
xin = [(@tilewidth - (@cursorbitmap.width / 4)) / 2, -expand,
@tilewidth - (@cursorbitmap.width / 4) + expand, (@tilewidth - (@cursorbitmap.width / 4)) / 2]
yin = [@tileheight - (@cursorbitmap.height / 2) + expand, (@tileheight - (@cursorbitmap.height / 2)) / 2,
(@tileheight - (@cursorbitmap.height / 2)) / 2, -expand]
for i in 0...4
if @arrows[i]
self.bitmap.blt(x + xin[i], y + yin[i], @cursorbitmap.bitmap,
Rect.new(@cursorbitmap.width / 2 + (i % 2) * (@cursorbitmap.width / 4),
Rect.new((@cursorbitmap.width / 2) + ((i % 2) * (@cursorbitmap.width / 4)),
(i / 2) * (@cursorbitmap.height / 2),
@cursorbitmap.width / 4, @cursorbitmap.height / 2))
end
@@ -96,7 +96,7 @@ class TilePuzzleScene
def update
xtop = (Graphics.width - (@tilewidth * @boardwidth)) / 2
ytop = (Graphics.height - (@tileheight * @boardheight)) / 2 + @tileheight / 2 - 32
ytop = ((Graphics.height - (@tileheight * @boardheight)) / 2) + (@tileheight / 2) - 32
for i in 0...@boardwidth * @boardheight
pos = -1
for j in 0...@tiles.length
@@ -112,13 +112,13 @@ class TilePuzzleScene
thisx = xtop
if pos >= 0
if pos >= @boardwidth * @boardheight
thisx = (xtop - (@tilewidth * (@boardwidth / 2).ceil)) / 2 - 10
thisx = ((xtop - (@tilewidth * (@boardwidth / 2).ceil)) / 2) - 10
if (pos % @boardwidth) >= (@boardwidth / 2).ceil
thisx = Graphics.width - thisx - @tilewidth * @boardwidth
thisx = Graphics.width - thisx - (@tilewidth * @boardwidth)
end
end
@sprites["tile#{i}"].x = thisx + @tilewidth * (pos % @boardwidth) + @tilewidth / 2
@sprites["tile#{i}"].y = ytop + @tileheight * ((pos % (@boardwidth * @boardheight)) / @boardwidth)
@sprites["tile#{i}"].x = thisx + (@tilewidth * (pos % @boardwidth)) + (@tilewidth / 2)
@sprites["tile#{i}"].y = ytop + (@tileheight * ((pos % (@boardwidth * @boardheight)) / @boardwidth))
next if @game == 3
rotatebitmaps = [@tilebitmap, @tilebitmap1, @tilebitmap2, @tilebitmap3]
@sprites["tile#{i}"].bitmap.clear
@@ -173,7 +173,7 @@ class TilePuzzleScene
@sprites["tile#{i}"] = BitmapSprite.new(@tilewidth, @tileheight, @viewport)
@sprites["tile#{i}"].ox = @tilewidth / 2
@sprites["tile#{i}"].oy = @tileheight / 2
break if @game == 3 && i >= @boardwidth * @boardheight - 1
break if @game == 3 && i >= (@boardwidth * @boardheight) - 1
@sprites["tile#{i}"].bitmap.blt(0, 0, @tilebitmap.bitmap,
Rect.new(@tilewidth * (i % @boardwidth), @tileheight * (i / @boardwidth), @tilewidth, @tileheight))
end
@@ -210,17 +210,16 @@ class TilePuzzleScene
num = 0
blank = -1
for i in 0...ret.length - 1
blank = i if ret[i] == @boardwidth * @boardheight - 1
blank = i if ret[i] == (@boardwidth * @boardheight) - 1
for j in i...ret.length
num += 1 if ret[j] < ret[i] && ret[i] != @boardwidth * @boardheight - 1 &&
ret[j] != @boardwidth * @boardheight - 1
num += 1 if ret[j] < ret[i] && ret[i] != (@boardwidth * @boardheight) - 1 &&
ret[j] != (@boardwidth * @boardheight) - 1
end
end
if @boardwidth.odd?
ret = pbShuffleTiles if num.odd?
else
ret = pbShuffleTiles if !((num.even? && (@boardheight - (blank / @boardwidth)).odd?) ||
(num.odd? && (@boardheight - (blank / @boardwidth)).even?))
elsif num.even? == (@boardheight - (blank / @boardwidth)).even?
ret = pbShuffleTiles
end
end
if @game == 1 || @game == 2
@@ -242,7 +241,7 @@ class TilePuzzleScene
def pbDefaultCursorPosition
if @game == 3
for i in 0...@boardwidth * @boardheight
return i if @tiles[i] == @boardwidth * @boardheight - 1
return i if @tiles[i] == (@boardwidth * @boardheight) - 1
end
end
return 0
@@ -255,16 +254,14 @@ class TilePuzzleScene
when 4
if pos >= @boardwidth * @boardheight
if pos % @boardwidth == (@boardwidth / 2).ceil
pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth + @boardwidth - 1
pos = (((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth) + @boardwidth - 1
else
pos -= 1
end
elsif (pos % @boardwidth) == 0
pos = (((pos / @boardwidth) + @boardheight) * @boardwidth) + (@boardwidth / 2).ceil - 1
else
if (pos % @boardwidth) == 0
pos = (((pos / @boardwidth) + @boardheight) * @boardwidth) + (@boardwidth / 2).ceil - 1
else
pos -= 1
end
pos -= 1
end
when 6
if pos >= @boardwidth * @boardheight
@@ -273,12 +270,10 @@ class TilePuzzleScene
else
pos += 1
end
elsif pos % @boardwidth >= @boardwidth - 1
pos = (((pos / @boardwidth) + @boardheight) * @boardwidth) + (@boardwidth / 2).ceil
else
if pos % @boardwidth >= @boardwidth - 1
pos = (((pos / @boardwidth) + @boardheight) * @boardwidth) + (@boardwidth / 2).ceil
else
pos += 1
end
pos += 1
end
when 8
pos -= @boardwidth
@@ -420,7 +415,7 @@ class TilePuzzleScene
cursor += (@boardwidth * dist)
end
for i in 0...@boardheight
tiles.push(cursor - i * dist * @boardwidth)
tiles.push(cursor - (i * dist * @boardwidth))
end
else
dist = dir - 5
@@ -429,7 +424,7 @@ class TilePuzzleScene
cursor -= dist
end
for i in 0...@boardwidth
tiles.push(cursor + i * dist)
tiles.push(cursor + (i * dist))
end
end
# Shift tiles
@@ -508,7 +503,7 @@ class TilePuzzleScene
if pbCheckWin
@sprites["cursor"].visible = false
if @game == 3
extratile = @sprites["tile#{@boardwidth * @boardheight - 1}"]
extratile = @sprites["tile#{(@boardwidth * @boardheight) - 1}"]
extratile.bitmap.clear
extratile.bitmap.blt(0, 0, @tilebitmap.bitmap,
Rect.new(@tilewidth * (@boardwidth - 1), @tileheight * (@boardheight - 1),