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("ƒ}ƒbƒvƒ`ƒbƒv", My.Resources.map, Helper.TransparentColor.None)

            w.SpriteCreate("”wŒi1", 640, 480)
            w.SpriteShow("”wŒi1")

            w.SpriteCreate("”wŒi2", 640, 480)
            w.SpriteShow("”wŒi2")

            For i = 0 To 14
                For j = 0 To 19
                    intRnd = objRnd.Next(0, 3)
                    w.SpriteCopy("”wŒi1", j * MAPCHIP_SIZE, i * MAPCHIP_SIZE, "ƒ}ƒbƒvƒ`ƒbƒv", intRnd * MAPCHIP_SIZE, 0, MAPCHIP_SIZE, MAPCHIP_SIZE)
                Next
            Next

            w.SpriteCopy("”wŒi2", 0, 0, "”wŒi1", 0, 0, 640, 480)

            Do
                w.SpritePosition("”wŒi1", 0, 0, intScroll)
                w.SpritePosition("”wŒi2", 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