Results 1 to 5 of 5

Thread: Scrolling background

                  
   
  1. #1
    DCEmu Newbie
    Join Date
    Nov 2005
    Posts
    41
    Rep Power
    0

    Question Scrolling background

    I'm attempting to make my first Lua game. Its a side scrolling shooter and I'm trying to get the background to scroll. the approach I'm trying to use seems sound but I think the problem is that I'm not understanding the function
    Code:
    nil image:blit(x, y, Image source, [sourcex, sourcey, width, height], [alpha = true])
    Well I understand that the first x,y and image source is the size of my background and the background image itself. Its the second part I'm kinda fuzzy about. I also understand what the alpha is for.

    Can someone clearly explain what the second part is? My idea for scrolling the background is to do this:

    1. clear the screen
    2. blit the background minus 8,272 of the background image
    3. blit the missing 8,272 at the end of the previous blit.

    If someone know a better way to scroll the background I'm all ears

  2. #2

    Default

    the second part represent the portion of the image you want to blit.

    sourcex and sourcey are the x and y position of the portion of the image you want to have and width and height are the length in the x and y direction.

    To take the whole image you have to select:
    screen:blit(0, 0, image, 0, 0, image:width(), image:height(), true)

    For the scrolling you can maybe have an image bigger than the screen and just change the sourcex and sourcey of the image source with 480 as width and 272 as height (if the scrolling is for the whole screen).

    Did never tried it, it's just an idea.

  3. #3
    Wii User shiftybill's Avatar
    Join Date
    Nov 2005
    Location
    The dark side of the moon
    Posts
    221
    Rep Power
    68

    Default

    hey i needed one of these so i made one
    background.png should be 240x272
    System.usbDiskModeActivate()
    background = Image.load("Background.png")
    x = 0
    x2 = 480


    while true do

    screen:blit(x, 0, background, false)
    x = x - 1
    screen:blit(x2, 0, background, false)
    x2= x2 - 1

    if x < -480 then
    x = 480
    end
    if x2 < -480 then
    x2 = 480
    end

    screen.waitVblankStart()
    screen.flip()
    end

  4. #4
    DCEmu Newbie
    Join Date
    Nov 2005
    Posts
    41
    Rep Power
    0

    Default

    Thanks guys, I'll check these out

  5. #5
    Wii User shiftybill's Avatar
    Join Date
    Nov 2005
    Location
    The dark side of the moon
    Posts
    221
    Rep Power
    68

    Default

    im using my background code in my shooter game which should be ready for a release soon!! 1945 eat ya heart out!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •