Results 1 to 7 of 7

Thread: Lua Help

                  
   
  1. #1
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    33
    Posts
    4,123
    Rep Power
    93

    Default Lua Help

    Here is my code what i would like is cars that you will have to dodge out the way but i dont know what the bit of code would be can someone help please.


    ----------------------------------------------------------------

    -- Created by splodger15

    Room_width = 480
    Room_height = 272
    player1x = 15
    player1y = 136
    background =Image.load ("images/road.jpg")
    player1=Image.load("images/car.JPG")

    ------functions
    function checkcontrols()
    pad = Controls.read()
    if pad:start() then
    exit = true
    end
    if pad:right() then
    player1x = player1x +2
    end
    if pad:left() then
    player1x = player1x - 2
    end
    if pad:up() then
    player1y = player1y - 2
    end
    if pad:down() then
    player1y = player1y +2
    end
    end
    function drawall()
    screen:blit (0,0,background)
    screen:blit(player1x,player1y,player1)
    screen.waitVblankStart()
    screen.flip()

    end
    -- MAIN LOOP
    while true do
    if exit == true then
    break
    end
    checkcontrols()
    drawall()

    end

    PSN ID: splodger15

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    I would like to see your try at the code before 'correcting' the code otherwise we be just doing it for you.

    Your first task would be to get cars moving on thier own from right to left or whatever direction.

  3. #3
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    33
    Posts
    4,123
    Rep Power
    93

    Default

    I only know very basic Lua

    PSN ID: splodger15

  4. #4
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Getting a car to move from right to left doesn't take any more knowledge then what you already know from the code you posted.

  5. #5
    DCEmu Old Pro
    Join Date
    Sep 2006
    Location
    Sheffield, UK
    Posts
    1,629
    Rep Power
    92

    Default

    One word. Timer, random. That should be all you need.

    Cloudy

  6. #6
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    33
    Posts
    4,123
    Rep Power
    93

    Default

    I am not sure what the code would be

    PSN ID: splodger15

  7. #7
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Lets put it this way, if you wanted to move the player left every frame without the player needing to press the D-pad, what would you do?

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
  •