Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
24 May, 2013, 23:04:44 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: My first Lua project: Galaga -  (Read 774 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
adriweb
Editor
LV9 Veteran (Next: 1337)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 12:02:44
Date Registered: 13 April, 2011, 18:42:59
Location: South of France
Posts: 1197


Total Post Ratings: +185

View Profile WWW
« on: 12 November, 2011, 11:56:38 »
0

This is what I did for my blockbreaker : it handles a basic linear acceleration/deceleration (the "dx" part)
This allows the paddle (or whatever is moving) to have a smooth scrolling.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
the paddleStuff function gets called when the ball(s) move(s) via a timer, from on.paint, basically)   

    ...

    function on.arrowKey(key)
        if key == "right" and paddle.x < platform.window:width()-20-XLimit then
            paddle.dx = 8
        elseif key == "left" and paddle.x >= 25 then
            paddle.dx = -8
        end
    end
    ...

    function paddleStuff(gc)
       if paddle.dx > 0 then
           paddle.x = paddle.x + paddle.dx
           paddle.dx = paddle.dx - 1 -- more if on-calc
       elseif paddle.dx < 0 then
           paddle.x = paddle.x + paddle.dx
           paddle.dx = paddle.dx + 1 -- more if on-calc
       end
    end
« Last Edit: 12 November, 2011, 12:04:36 by adriweb » Logged


TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.212 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.