Results 1 to 2 of 2

Thread: Problem with analog stick

                  
   
  1. #1

    Default Problem with analog stick

    ok been looking around for info on analog stick and there's not much out there

    here's my problem

    I have an image with a big thick red line and a dot I am moving around with the analog stick, I use the pixel detection for this and tell it if you touch red pixel stop.

    so far it works, but what I really want, and that I just can't figure out, is I want my dot not to stop but just be block from passage in the red zone.

    red = Color.new(255, 0, 0)

    dot = Image.load("DATA/dot.png")
    bgC = Image.load("DATA/bg col2.png")

    x0 = 0 ; y0 = 0 ; x1 = 0 ; y1 = 0
    while true do

    screen:clear()
    pad = Controls.read()

    dx = pad:analogX()
    if math.abs(dx) > 32 then
    x0 = x0 + dx / 64
    end
    dy = pad:analogY()
    if math.abs(dy) > 32 then
    y0 = y0 + dy / 64
    end

    if bgCixel (x1, y1) == red then

    x1 = x1 ; y1 = y1 else
    x1 = x0 ; y1 = y0

    end

    screen:blit(0, 0, bgC)
    screen:blit(x1, y1, dot)
    screen.waitVblankStart()
    screen.flip()

    if pad:start() then break end

    end
    so if someone could help it be appreciate

  2. #2
    DCEmu Newbie
    Join Date
    Mar 2006
    Posts
    5
    Rep Power
    0

    Lightbulb

    Code:
    analogPad = Controls.read() 
       dx = analogPad:analogX() 
       dy = analogPad:analogY() 
    
    
    
    
    
    -- Analog up, down, right & left
    
       if (dx > -45 and dx < 44 and dy == -128) then  
       sound3:play() 
    end
       if (dx > -45 and dx < 44 and dy == 127) then
          sound4:play() 
    end
       if dy > -45 and dy < 44 and dx == 127 then 
          sound3:play()
    end 
       if dy > -45 and dy < 44 and dx == -128 then 
          sound4:play() 
    end
    this is the code i use for my app

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
  •