-- this is run when dink is loaded, directly after the dink.ini file
-- is processed.
-- ackshually, it's run after main.lua

function main()

 dink.debug("Loading sounds..")
 dink.load_sound("QUACK.WAV", 1)
 dink.load_sound("PIG1.WAV", 2)
 dink.load_sound("PIG2.WAV", 3)
 dink.load_sound("PIG3.WAV", 4)
 dink.load_sound("PIG4.WAV", 5)
 dink.load_sound("BURN.WAV", 6)
 dink.load_sound("OPEN.WAV", 7)
 dink.load_sound("SWING.WAV", 8)
 dink.load_sound("PUNCH.WAV", 9)
 dink.load_sound("SWORD2.WAV", 10)
 dink.load_sound("SELECT.WAV", 11)
 dink.load_sound("WSCREAM.WAV", 12)
 dink.load_sound("PICKER.WAV", 13)
 dink.load_sound("GOLD.WAV", 14)
 dink.load_sound("GRUNT1.WAV", 15)
 dink.load_sound("GRUNT2.WAV", 16)
 dink.load_sound("SEL1.WAV", 17)
 dink.load_sound("ESCAPE.WAV", 18)
 dink.load_sound("NONO.WAV", 19)
 dink.load_sound("SEL2.WAV", 20)
 dink.load_sound("SEL3.WAV", 21)
 dink.load_sound("HIGH2.WAV", 22)
 dink.load_sound("FIRE.WAV", 23)
 dink.load_sound("SPELL1.WAV", 24)
 
 --sound slot 25 is free - dupliate sound was loaded in here by default 
--(duplicate of CAVEENT.WAV, see slot 32 further down)
 --Feel free to use this slot first if you need to add custom sounds
 --load_sound("CAVEENT.WAV", 25) 
 
 dink.load_sound("SNARL1.WAV", 26)
 dink.load_sound("SNARL2.WAV", 27)
 dink.load_sound("SNARL3.WAV", 28)
 dink.load_sound("HURT1.WAV", 29)
 dink.load_sound("HURT2.WAV", 30)
 dink.load_sound("ATTACK1.WAV", 31)
 dink.load_sound("CAVEENT.WAV", 32)
 dink.load_sound("LEVEL.WAV", 33)
 dink.load_sound("SAVE.WAV", 34)
 dink.load_sound("SPLASH.WAV", 35)
 dink.load_sound("SWORD1.WAV", 36)
 dink.load_sound("BHIT.WAV", 37)
 dink.load_sound("SQUISH.WAV", 38)
 dink.load_sound("STAIRS.WAV", 39)
 dink.load_sound("STEPS.WAV", 40)
 dink.load_sound("ARROW.WAV", 41)
 dink.load_sound("FLYBY.WAV", 42)
 dink.load_sound("SECRET.WAV", 43)
 dink.load_sound("BOW1.WAV", 44)
 dink.load_sound("KNOCK.WAV", 45)
 dink.load_sound("DRAG1.WAV", 46)
 dink.load_sound("DRAG2.WAV", 47)
 dink.load_sound("AXE.WAV", 48)
 dink.load_sound("BIRD1.WAV", 49)

 -- These sounds are missing from Original Dink's start.c, but they exist in the sound folder. Uncomment to use
 -- dink.load_sound("BIRD2.WAV",50)
 -- dink.load_sound("POP.WAV",51)
 -- dink.load_sound("HIGH1.WAV",52)

 -- make sure they're in 24-bit mode


dink.fill_screen(0)
dink.screenlock(0)
player.seq = 0
player.brain = brain.MOUSE
player.pseq = 10
player.pframe = 8
player.que = 20000
player.noclip = true

local crap = dink.create_sprite(426, 344, brain.NONE, 192, 1)
crap.que = -800
crap.noclip = true

dink.say_xy("`%Starting new game. Please wait.", 0, 394)
dink.wait(1)

-- This is where you would change the room Dink starts in!!
global.player_map = 400

--This is where you would change the location Dink is going to show up
player.x = 180
player.y = 250

--Change dink from a mouse pointer into a human being. :)
player.base_walk = 70
player.base_attack = 100
dink.set_mode(2)
dink.reset_timer()
player.dir = direction.SOUTH
player.brain = brain.PLAYER
player.que = 0
player.noclip = false

--set Dinks initial stats
global.strength = 3
global.defense = 2
global.magic = 1
global.gold = 25

--lets give him fists to start out with, and arm him with the fists.
dink.add_item("item-fst", 438, 1)
global.cur_weapon = 1
dink.arm_weapon()

--Clear the screen black in preparation for the first room of the game.
dink.fill_screen(0)

--Turn on the status bar
global.update_status = 1
dink.draw_status()

--We're done, so let's kill this task & the game will begin!
dink.kill_this_task()

-- Make a table for our buttons
local btable = {}

--Create the START button....
local crap1 = dink.create_sprite(76, 434, brain.BUTTON, 194, 1)
crap1.script = "start-1"
table.insert(btable, crap1)

--Create the CONTINUE button....
local crap2 = dink.create_sprite(314, 434, brain.BUTTON, 195, 1)
crap2.script = "start-2"
table.insert(btable, crap2)

--Create the QUIT button....
local crap3 = dink.create_sprite(560, 434, brain.BUTTON, 193, 1)
crap3.script = "start-3"
table.insert(btable, crap3)

-- Set all our buttons to noclip and touch damage -1
for k, v in pairs(btable) do
  v.noclip = true
  v.touch_damage = -1
end

--If you're going to play a title midi, uncomment & change the following:
-- dink.playmidi("title.mid")

dink.kill_this_task()

end
