Imports System.Drawing
Imports System.Windows.Forms
Imports Wakaba

Module Module1

    Private Const MAPCHIP_SIZE As Integer = 32
    Private Const SCROLL_SPEED As Integer = 4

    Private w As Wakaba.Helper

    Sub Main()

        Try
            Dim i As Integer
            Dim j As Integer
            Dim objRnd As New Random
            Dim intRnd As Integer
            Dim intScroll As Integer = 0

            w = New Wakaba.Helper
            w.Initialize()

            w.SpriteCreate("}bv`bv", My.Resources.map, Helper.TransparentColor.None)

            w.SpriteCreate("wi1", 640, 480)
            w.SpriteShow("wi1")

            w.SpriteCreate("wi2", 640, 480)
            w.SpriteShow("wi2")

            For i = 0 To 14
                For j = 0 To 19
                    intRnd = objRnd.Next(0, 3)
                    w.SpriteCopy("wi1", j * MAPCHIP_SIZE, i * MAPCHIP_SIZE, "}bv`bv", intRnd * MAPCHIP_SIZE, 0, MAPCHIP_SIZE, MAPCHIP_SIZE)
                Next
            Next

            w.SpriteCopy("wi2", 0, 0, "wi1", 0, 0, 640, 480)

            Do
                w.SpritePosition("wi1", 0, 0, intScroll)
                w.SpritePosition("wi2", 0, 0, intScroll - 480)

                intScroll += SCROLL_SPEED
                If intScroll > 480 Then
                    intScroll = 0
                End If

                w.ScreenRefresh(True)

            Loop While Not w.WindowClosing

        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace)
        End Try

        w.Dispose()

    End Sub

End Module