water.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. -- title: water
  2. -- author: pixelbath
  3. -- desc: reference for water effect
  4. -- create a mapping for darkening palette colors
  5. -- note: this is for the default sweetie16 palette
  6. drk={[0]=0,0,1,2,3,6,7,15,0,8,9,10,13,14,15,0}
  7. function drawStars(count, seed)
  8. math.randomseed(seed)
  9. for i=1, count do
  10. x=math.random(0,239)
  11. y=math.random(0,68)
  12. r=math.random(0,1)
  13. pix(x, y, 12)
  14. end
  15. end
  16. function doWater(posY)
  17. t=time()/200
  18. for x=0,239 do
  19. for y=posY,135 do
  20. -- introduce some wobble
  21. ox=x+2*math.sin(t+y)
  22. oy=posY-(y-posY)-1
  23. oc=pix(ox,oy)
  24. -- darken reflected pixel
  25. pix(x,y,drk[oc])
  26. end
  27. end
  28. end
  29. function TIC()
  30. cls(15)
  31. drawStars(25, 0)
  32. map(0,0,30,17,0,0,0)
  33. doWater(68)
  34. end
  35. -- <TILES>
  36. -- 066:0000000000000000000000000000000000000007000000070000000700000007
  37. -- 067:0000000000000000000000000000000070000000770000007700000077000000
  38. -- 081:0000000000000000007700000077000000770000077770000777700007777000
  39. -- 082:0000007700000077000000770000077700000777000077770000777700007777
  40. -- 083:7770000077700000777000007770000077770000777700007777700777777007
  41. -- 084:0770000007700000777000007770000077700000777000007777000077770007
  42. -- 085:0000000000000000000000000000000077000000777000007777000077770000
  43. -- 096:0000000000000000000000000000000d00000ddd000ddddd00dddddddddddddd
  44. -- 097:77777700777777dd777777dd7777777d7777777d7777777d7777777d7777777d
  45. -- 098:0dd77777ddd77777dd777777dd777777dd777777dd777777dd777777dd777777
  46. -- 099:77777dd777777dd777777dd777777dd777777ddd77777ddd77777ddd77777ddd
  47. -- 100:7777000777770077777700777777dd777777dd77dddddd77dddddd77dddddd77
  48. -- 101:77777000777770007777700077777000777770007777700077777d0077777ddd
  49. -- 105:00000000000000000000000000000000000000000000000000000000000000dd
  50. -- 106:0000000000000000000000000000000d0000dddd00dddddddddddddddddddddd
  51. -- 107:000000000000000000000000dddddddddddddddddddddddddddddddddddddddd
  52. -- 108:000000000000000000000000dd000000ddddd000ddddddd0dddddddddddddddd
  53. -- 112:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  54. -- 113:dd777ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  55. -- 114:dd777777ddd77777ddddd777dddddddddddddddddddddddddddddddddddddddd
  56. -- 115:77777ddd7777dddd7ddddddddddddddddddddddddddddddddddddddddddddddd
  57. -- 116:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  58. -- 117:777ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  59. -- 118:ddd00000dddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  60. -- 119:00000000d0000000dddddddddddddddddddddddddddddddddddddddddddddddd
  61. -- 120:0000000000000000dddddddddddddddddddddddddddddddddddddddddddddddd
  62. -- 121:000ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  63. -- 122:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  64. -- 123:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  65. -- 124:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  66. -- 125:d0000000dd000000dddd0000dddddd00dddddddddddddddddddddddddddddddd
  67. -- 126:00000000000000000000000000000000dd000000ddddd000dddddddddddddddd
  68. -- 127:000000000000000000000000000000000000000000000000d0000000dddd0000
  69. -- </TILES>
  70. -- <MAP>
  71. -- 004:03132333435363738393a3b3c3d3e3f30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  72. -- 005:04142434445464748494a4b4c4d4e4f40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  73. -- 006:05152535455565758595a5b5c5d5e5f50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  74. -- 007:06162636465666768696a6b6c6d6e6f60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  75. -- 008:07172737475767778797a7b7c7d7e7f70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  76. -- </MAP>
  77. -- <PALETTE>
  78. -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
  79. -- </PALETTE>