Getting input with IUP in Lua -


I am trying to get input with IUP to create a short pong game. I wanted to try some input, and tried some code coming along with IUPGL examples, but the input does not work at all. Here's the code as it stands so far:

  is there "iuplua" to occur "iupluagl" to occur "luagl" paddle = {x = -0.9 necessity requirement, y = 0.2} function drawPaddle (x, y) gl.Begin (gl.QUADS) gl.Color (0.0, 0.5, 0.0) gl.Vertex (x, y) gl.Vertex (x + 0.1, y) gl.Vertex (X + 0.1, Y - 0.4) GL Vertex (x, y - 0.4) at the end canvas = iup.glcanvas {buffer = "double", rastersize = "300x300"} function canvas: action (x, y) IupkGLMakeCurrent (self) gl.ClearColor (0.0, 0.0, 0.0, 0.0) Glkkliyr (Glkklr_bfr_bit) Glkkliyr (Glkdepth_bfr_bit) Glkmatrishmode (Glkprojekshn) Glkviawport (0, 0, 300, 300) Glkloadidentiti () Draupdale (Pddlkksh , Paddleky) GlkEnd () IupkGLSwapBuffers (self) end window = iup.dialog {canvas, title = "soon"} function canvas to Pong: k_any (c) If c == iup.K_q return Iup.CLOSE elseif c == iup.K_w then paddle.y = paddle.y + 0.02 return iup.CONTINUE and return iup.DEFAULT finally end windo w: show () iup.MainLoop ()  

this is my That is the canvas: k_any () When a key is called pressing, but this is not an answer, even a thought for quitting order?

This is the least part of the problem for the sample you have quoted. Before defining the IUP keyname constant in your iup table, you have to call the function. The idea is that the memory footprint is low if you do not need all the key names, which can not be done without completely completing many applications.

Try adding the following lines shortly after some time requires "iuplua" and before you use the name in any code:

< Pre> iup.key_open () - load key name

This document is near the top of the subject keyboard code and also in various places related to the keyboard.

iup.key_open () , iup.k_q evaluates zero without calls Other key is name) and thus quietly canvas: k_any () .

Edit: does not match any keycode, code> iup.key_open () is caused by recognizing Q & W keys as you have There is another disturbance that you will notice next, that updating the pedal position will not be asked to redraw the canvas.

Edit2: Adding the line iup.update (self) to the function canvas: k_any () If you modify the situation, what you want is it seems that instead of calling the action () method manually, it is expected that by doing the IUP's message loop handling, the expected methods Should interact with In the general case, instead of calling iup.updateChildren (windows) it can be liked, it will create any other IUP controls that display in the updated dialog as well as in the canvas. Which can be useful if you have controls that do not update internally.

Alternatively, move the drawing routine to its own function, which can be found in both k_any () and operations () canvas methods Is called from. I'm not sure that I generally recommend it because when you want to support multiple viewport or related controls, then it's not even on the scale.

You want to rearrange your logic in K_any () handler so that you accidentally forget to call iup.update () As you are adding cases for the new key.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -