I am trying to figure this out. I have found the information I just don’t know how to incorporate it with this specific code.
I understand it’s frustrating that I won’t just give the answer. Think of it as tough love, I want to help you think like a programmer. The clues I’m giving aren’t hitting home because the very foundations of lua coding, or even coding in general, aren’t there. We all had to go through the tutorials and example code, there are no shortcuts.
Rob may kindly come along with the exact code you need in a minute, but I’m not convinced that helps long term if you just plug it in and move onto the next problem.
Just for fun, here is a basic bingo game written for Corona using SSK2.
Time to write ~1 hour
Lines of code including blanks and comments: 225
Code: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/09/bingo.zip
Game in action:
https://www.youtube.com/watch?v=unBusx-duMw
It should be easy to understand, but be aware I made use of plenty of SSK 2 features and some advanced coding because I’m just too lazy to make a beginners version.
PS - I agree w/ the idea that you should code this on your own. Now, you have the wonderful docs and examples on the site plus this working ‘example’ to refer to for the logic of layout and checking for a win.
I suggest you now write your own version of the game to see if you can based on all this. In doing so, you will learn many things and hit many roadblocks.
Have fun and good luck.
PPS - This is about my whole week’s time for help so I won’t be answering any ‘how do I X’ questions as related to the example. Anyways, I think you’ve got enough now to get rolling.
Unfortunately, I can’t write your project for you. Like Nick, I want to see you succeed, but you can’t if you have someone do all the work for you. If you want a BINGO game but don’t want to put in the work, or perhaps you want to do the graphical side and need help with programming, you could go to our Jobs board and hire a Corona developer to provide you the code side to your art.
But the presumption here is when you ask programming questions, you’re wanting to be the programmer on the project and there are certain expectations and learning programming basics is one of those.
You can’t take code snippets from multiple programmers and expect them to work together. In particular, taking example code from the documentation is notorious for demonstrating this.
Code in documentation samples have no clue how you will use it. Almost no one will have a text object name “myText”? Why? because it has no meaning / relevance to your project. In BINGO for instance, you’re going to have multiple text items. Each number is a text object. You may have a title object. You may have some instruction text. None of these uses of text makes sense to name “myText”. But when writing documentation, you have to write it in a very generic “I don’t know how you will use it” situation. There “myText” is probably as good of a variable name as any. I guess “someTextLableYouWillRenameLaterBasedOnYourUsage” might be more appropriate, but that would just look totally ugly in the docs.
In other words, the documentation code samples are not designed to be 100% copy/paste. There is an assumption you will adapt it to your specific needs making your own decisions.
Rob
Perhaps I should explain this project to you.
I work with a non-profit television channel. I am not paid for my services. I wanted to produce a local Bingo program. Rather than giving out cards I wanted to create an app. I wanted this app to do a few basic things.
-
Create a random set of Bingo numbers. (Thank you for that)
-
Allow the player to select the numbers and when they have a row across have a bingo button appear that they could push and would take a screen shot of their numbers (if possible) and send a message to us that they had gotten the Bingo with contact info so we could call them.
-
Be able to display the live stream that we have to our website. If possible to have it be audio or video or neither if they are watching it live.
I have had to learn all kinds of different systems over the years. My goal isn’t to start a game making business it is just to produce this one simple function. The station has no budget and I didn’t want to hire it out so I volunteered to do it. I know this isn’t your problem and perhaps I have gotten in over my head.
From the information I see online and what you have given me I can see this is absolutely possible. I have from other tutorials figured out how to put backgrounds in. I have the page working with the squares and the numbers thanks to you. I am now trying to incorporate the information with the tic tac toe game on how to make the select the squares and have it pronounce a winner. I would also like, if possible to change the font color. I haven’t been able to figure these out. Once again, I know that I could figure out how to do this if I would only commit to days, weeks, months or research. I don’t have that much time. If I am spending a weekend in Mexico I don’t want to have to major in Spanish in college for 4 years to do so. The web pages say there is help in the forums. If I can’t get help I will have to abandon this and try something else.
As you have seen, programming is not easy. If you don’t have the sort of time required, the app you’re describing is not realistic at all.
It might seem like a ‘simple function’, but I would venture there’s years of experience required to produce that design in the timeframe you’re talking about, and have it good enough to release into the wild to your viewers. RG makes it look easy with his example, but there’s a LOT of hard work to get to that level.
There is help in the forums, but the help you need is to basically code the app from start to finish - or teach you how to code it from start to finish.
Hi again. It just occurred to me that I may have the win checking code slightly wrong. You should not check the rows, just columns and diagonals.
I haven’t played Bingo and over 20 years and I was thinking more about tic-tac-toe as I wrote that bit of code.
Do you mean, the TV channel will televise the choices and people will be able to play along on their devices?
If so, that is a not insignificant project and will require:
- Game Server - To choose numbers and allow users to connect and play along
- Some way to display game server choices on a screen or other device so you can broadcast that.
- app(s) in Android and/or iOS stores. This app will need to implement multi-player code if you want players to be able to play along with the server.
#1 Will cost money and/or significant experience/knowledge.
#2 can be done w/ Corona but it will require some expertise.
#3 can be done with Corona for a low cost, and medium effort, but you’ll have to know quite a lot.
What I said for #2 and #3 are true for all game engines and sdk that I am familiar with. i.e. While the solutions may vary, the fundamentals stay the same.
I don’t think the design is as complex as that Ed, I think it’s all local to the device, just watching along with the channel, with the ability to e-mail in a screenshot and phone number if the numbers on your device match those drawn on TV.
Even so, not a beginner’s project and requiring a certain amount of honesty on behalf of the viewers…
You can’t code apps without learning how to code. That has nothing to do with Corona. Whatever framework you had chosen, you still need to learn what a variable is, how to break down problems into coding logic, and how to read API documents.
That takes time. Time you don’t have. If you don’t have the time, why should anyone else?
Rob is a Corona employee, but he is paid to assist, not teach you the basics of coding. The rest of us volunteer time freely to help people who are in the position we were once in ourselves, with the understanding that we expect them to put in the same effort we did when we were learning. Some offer coding services, but RoamingGamer gives up tens of thousands of pounds worth of free time and code every year. He’s certainly not here to make a quick buck.
I learnt C64 basic when I was 8 without a manual. There was no Internet. One day one of the games I was playing crashed and I found I could look at the code, and I was away. You have a billion pages on Google related to programming, all the Corona API docs, tutorials, example code, all the resources necessary to code anything you can imagine. If you don’t have the time, that’s unfortunate, but your expectations of the forum are completely unrealistic.
No-one from Corona is trying to get money from you. The fact we get this incredible game engine for free is amazing in itself. 10-15 years ago, you’d have been paying $10,000 a year per seat for a tool with this power.
I can see you’re frustrated and I’m sorry that is the case.
However, I think you’ve got some things mixed up here.
-
So far, with the exception of Rob, everyone who has answered you is not staff. Put another way, we are all just folks (Corona users) taking time out from our money making working hours to try to give some help or pointers to folks in the forums.
-
You’re not a client. You’re a user. There is a big difference. A client is a person who has paid for a service. I think you know this, but are just angry at this time. Again, I’m sorry if you are frustrated.
-
All of the things you listed are true:
- Easy-to-learn & powerful
- … yada yada
- More than 500,000 developers and an
- active, helpful forum
I think perhaps you’re sticking on the last bit. The forums activity varies by may factors, but it is fair to call it active. I rarely see a post go unanswered. i.e. without response.
Also, I feel helpful. I’ve posted almost 7000 times since 2014-ish, I have written and provided many libraries and tools for free to the community, I co-hosted a weekly YouTube show for Corona for several years, I have authored many templates, and I have provided over 400 fully coded solutions, examples and games:
I’m just one of many folks who do similar things for free for folks new and old.
The thing is, those of us who help have one focus: Helping users to learn to use Corona and solve problems on their own. OK, maybe that’s two focuses.
We (users taking time out from making money) are not here to write entire apps.
We want to help solve fundamental problems, but none of us can afford to do more. At least I can’t.
I would love to have you stay here and be successful, but if you feel this is not the place for you or that we’re all just terrible lying so-and-sos, You might try asking the same question in some other engine/sdk forums to see if we are bad or if it is the same everywhere.
If you’re familiar with Lua, you can try Defold and/or LÖVE. They are both pretty good and they have semi-active communities.
Best of luck to you on this. I hope you stay and continue to ask for help as needed.
Cheers,
Ed (aka the Roaming Gamer)
Haha, our posts look slightly out of context now…
Dang it. The post I responded to got deleted… sigh.
Oh well, I hope he stays and is successful on this.
I’m going to drop back to a different level of understanding here.
When you put something on the screen, be it a background image, a button to interact with, some piece of text (which includes number to display to users) You are creating a display object. All display objects have various properties that can be changed, properties that you can only look at, and methods or functions that let you do things a little more complicated that simply changing properties.
All display objects are typically stored in a variable so you can reference it easier:
local myText = display.newText("hello world", 100, 200, native.systemFont, 24)
will create a text string with the contents “hello world”, position it at 100 points left of your content area, 200 points down from the top of your content area, using a font called native.systemFontBold that’s 24 points high. The references to that display object will be stored in a variable named myText. There are other things like the color of text that default to preset values. Color for instance defaults to white.
Now, this is just an example. “myText” is probably one of the most useless variable names you can use. It has no meaning. Perhaps making the variable name something more practical like:
local welcomeText = display.newText("hello world", 100, 200, native.systemFont, 24)
would make more sense. A good programmer will use good variable names because if your app is full of “myText”, that really doesn’t say much. A table can contain multiple display objects. This is what your “spots” array is. Therefore “spots[1]” is a display object that you can manipulate.
You can change its value by changing the text property. Sticking with the second example, you can change the value by doing:
welcomeText.text = "Hello World! How are you?"
You will see the screen update with the new text. You can move it lower on the screen by changing it’s .y attribute:
welcomeText.y = 250
Now to change the color to red:
welcomeText:setFillColor( 1, 0, 0 )
You don’t have a welcome text, you have a table of spots, so to change the vertical position of the 3rd spot:
spots[3].y = 250
or more practically to change the middle item (13) to the text “Free” since it’s a free space in Bingo:
spots[13].text = "Free"
But if you consider my BINGO code I posted earlier, the free space is in the N column in the third slot:
N\_spots[3].text = "Free"
Hopefully, this will give you a critical piece that you’re missing.
Rob
Ah, @nick_sherman and @roaminggamer, I now see the missing post that was deleted. Mail notifications are a good thing
Just to clarify, we have over 500,000 developers. Most people come to the forums, learn how to use the product and don’t hang out here after they learn. But we have an active forum and there are quite a few very helpful developers who do hang out here offering help at no expense to the community (and the Staff at Corona Labs is eternally grateful for this).
Corona staff actively monitors the forums, but as to avoid dominating all the conversations, we have to pick and choose which topics we respond to. As such, if it’s a product-specific question, I feel we are the best to answer. If it’s a “How do I use the product” question, those are best for the community to answer. If I’m going about this in the wrong way, let me know. Our community developers build and deploy way more games than our staff does and therefore has more experience on what can be done with the product. This thread is a great example. I worked on a BINGO game back in the 1990’s on the server side in C. Not very practical on building a BINGO game in Corona, but @roaming_gamer has. He’s a much better resource to answer that “How do I” question…
We (Corona Labs) and I believe the community developers all want everyone to be successful and use Corona for years. As for lack of information, I’m pretty sure all of this is explained in our Getting Started Guide. http://docs.coronalabs.com/guide/programming/index.html
But all that said, tutorials have to be generic where possible, but there are times where they get very specific and that specificity is very unlikely going to directly translate to copy and paste code. Tutorials are there to teach you concepts that you will adapt to your own use.
Rob
I had received from Rob the code for a bingo game (Thank you so much) I have styled this around your tutorial on the Tic-Tac-Toe game where you have a reset button. The reset is has code of
local function resetGame() for i = 1, #spots do spots[i].moveText.text = " " spots[i].moveType = nil end display.remove( winningLine ) winningLine = nil display.remove( winningRec ) winningRec = nil display.remove( winningImage ) display.remove( resetButton ) resetButton = onPress player = "X" allowMoves = true end
This works well. Is there a way to add code to shuffle the numbers. I have tried virtually every combination that I could think of. The section of code to shuffle the bingo card is
local B = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } local I = { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 } local N = { 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 } local G = { 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58 ,59, 60 } local O = { 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75 } math.randomseed( os.time() ) -- Seed the pseudo-random number generator local function shuffleTable( t ) if ( type(t) ~= "table" ) then print( "WARNING: shuffleTable() function expects a table" ) return false end local j for i = #t, 2, -1 do j = math.random( i ) t[i], t[j] = t[j], t[i] end return t end shuffleTable( B ) shuffleTable( I ) shuffleTable( N ) shuffleTable( G ) shuffleTable( O )
Thanks again for your help.
Create a table with the valid numbers in it:
local bingoBalls = {} for i = 1, 75 do bingoBalls[i] = i end shuffleTable( bingoBalls )
Then just take the balls in order out of the shuffled list.
Rob
I put this into my code and made a button at the bottom of the code
local button3 = widget.newButton( { width = 60, height = 35, defaultFile = "btn green.png", overFile = "btn yellow.png", label = "", onPress = bingoBalls } ) -- Center the button button3.x = display.contentCenterX button3.y = display.contentCenterY -90 -- Change the button's label text button1:setLabel( "" )
Trying to reference it to shuffle the table. It doesn’t shuffle the numbers.
bingoBalls is not a function, it is a table containing a series of numbers.
You need to point onPress at a function that calls shuffleTable(bingoBalls).
How do I do that? I thought that was what I was doing.