Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - LRH

#1
Okay, that much makes sense. I think I get it now.  So once I've initially run a for loop with the number I wanted (like in spawn_flakes) they exist in the table, so everything that comes after that can use "#snowflake" ?

Edit: In any case, doing it that way certainly works. I just gave it a shot.
#2
Thanks for the reply, Crimson.

This is admittedly the area that's escaping me a bit. I'm not entirely sure what putting "#" does in syntax, because I'm unable to search the lua wiki for the singular character, and I'm not sure how it's referred to. (Pound? Number sign?)

How I understood it in the context was that it would essentially return the number of entries in a particular array- (or "table" in this case) is that right?

If so, wouldn't I need to specify that there's 100 snowflakes in the declaration of the table itself?  I thought that the "for" loop was essentially assigning 100 objects to the currently empty array, the way I had it before.

Apologies if anything I say is confusing.  I think I'm just having difficulty on a very basic level.
#3
Forgot to mention to you Gurok, but you were correct in assuming I'm using love2d.

If either of you are interested, the result of this:

Code: lua

snspr = love.graphics.newImage("SPR/snow.png")
flake_array = {}




function spawn_flakes()
	for i = 0, 100, 1 do
	flake_array[i] = {}
	flake_array[i].x = math.random(800)
	flake_array[i].y = math.random(600)
	end
end

function flake_update(dt)
	for i = 0 ,100, 1 do
		flake_array[i].x = flake_array[i].x + math.random(-50, 50) * dt
		flake_array[i].y = flake_array[i].y + 1
			if flake_array[i].y >= 600 then
				flake_array[i].y = 0
			end
	end
end

function flake_draw()
	for i = 0 ,100, 1 do
		love.graphics.draw(snspr, flake_array[i].x, flake_array[i].y)
	end
end


and placing the functions in their respective "Main.lua" functions results in this:
https://www.youtube.com/watch?v=jUnlYE316s4

Thanks for the help! I'm already understanding tables (and using them as arrays) much better.
#4
Wow, this community never ceases to amaze...

Thank you both, Gurok and Crimson.  I'm on the run right now but I'll definitely have some fun tinkering to do later!
#5
I have a question about programming in Lua- if this is a reasonable place to do so, that is.

I'm really excited to learn a language from the bottom up, since my only experience with programming before now has been limited to AGS script.  I'm working along pretty well.  What I've got right now is basically a background being drawn, with a player drawn on top of that.  I've also made a little function to check whether the arrow keys are being pressed, and if so, the player moves in the corresponding direction.  Super basic stuff.

However, in learning how to use tables, I'm finding myself having a hard time grasping some of the concept.  I've been doing something like this in order to assign the player's variables:

Code: ags


player = {}
player.x = 200
player.y = 300



and later making something like

Code: ags


function update_player()

    if isPressed("right") then
    player.x = player.x + 5
    end 
end


Oversimplified for the sake of example, of course.  But in any event, thinking ahead, I'd like to be able to enumerate something contained within a table, and the concept is a bit too ethereal for me to grasp right now.  What I mean to say is, what if I wanted to program something like snow falling? I know what the general concept is but I lack the knowledge to execute it.

What I imagine is having a variable number of snowflakes (so that I can decide later on how much snow I want there to be) which spawn across the top of the screen and float downward, then, each flake has its own sub-set of X,Y coordinates, and there's a bit of code which finds a random number to increase or decrease the X value by, so that the flakes drift a bit.

So!  After that long-winded nightmare...does anyone know how to accomplish what I'm talking about? :tongue:
#6
Wow, fantastic answers. Thank you both Bill and Snarky! I'm happy that I know how it all works now. :)
#7
My ignorance in the field of streaming things online has bothered me for ages but I've been too lazy to post about it. There's quite a lot I want to know, since I find it all very fascinating.

1.) When a video streams, what exactly is going on? Is the computer simply taking bits of information at a time and storing them temporarily as they play, or is it actually relying entirely on another computer and just acting as a medium in which to show you?

2.)Similar to the question above, how does...well, everything else work? As far as pictures and such... when you access a website with pictures and text, are the pictures and text temporarily saved to your computer while you view them? Or does the explorer simply show you pictures and text stored on another computer without the need to temporarily store them? Does this process vary depending on the file medium?

Sorry for packing so many questions into one post but my fundamental misunderstanding of how the internet works has been driving me crazy lately.
#8
I've been looking allllll over tonight but I have had no luck whatsoever.

I'm looking to trade in my old laptop for a portable device. I want something *like* an ipod touch, but not an ipod touch. I just really can't stand them.

Honestly the most important things to me are local radio and streaming video ability from youtube/netflix/etc. The zune would be perfect...only it doesn't support streaming. I've been looking at all sorts of things. I suppose even a small android "tablet" would work, but I'm having trouble finding something affordable that supports radio and streaming.

Any suggestions?
#9
Okay, a few questions:

1.) Is it possible to use some sort of phone to send video in real time to a computer? If so, which models, etc?

2.)Does anyone know of any legitimate writing/transcription jobs that allow telecommuting? I don't mind grunt work...I could use something though.
#10
The Rumpus Room / Re: Happy Birthday Thread!
Fri 08/04/2011 16:05:09
I already bid him a happy birthday in IRC so he doesn't get one here.


...


Yeah. That's right.  >:(



...



Oh okay fine. Happy Birthday Matt!
#11
Wow! :O

Way to go guys! :D
#12
While I'm here I actually have a very strange question. Ultimate Game Solutions is giving my site more traffic than AGS. Not complaining, it's actually kind of cool. But why is that? I've visited the site and I can't seem to find anything on why this could be. It's not like it's featured or anything.
#13
Quote from: Saren on Thu 06/01/2011 16:40:43
Oh and another one: When I import character images into AGS for sprites, how do make sure the white background that I drew them on doesn't appear in the game? I once downloaded some characters in a package just to see what they looked like and they were on pink backgrounds?

Well, when you go to import a sprite, you should see a little box asking you to choose a transparency color, usually by choosing a pixel in one of the four corners of the image file. For example, if you draw on a white background and you want white to be the transparent and unseen color, if white is the color of the pixel in the upper right corner, choose upper right corner from the drop down menu.
#14
That's it! Thank you!

Just watched it on netflix, never been a fan of Buffy before,but it was interesting! Also substantially less scary than it was 11 years ago :P Even a bit funny, at points.
#15
New question from Domithan!
Huzzah!

So it's this:
WHAT THE HELL MOVIE AM I THINKING OF?!
It's been driving me crazy.

Clearly I don't know the title, but I only caught a portion of it on TV when I was a kid and it scared the crap out of me. All I can remember was that there was that creatures from fairy tales came to life, silenced everyone, and was tearing our their hearts. Does this sound familiar to anyone?
#16
Hello, welcome to the forums!  8)
#17
The Rumpus Room / Re: Happy Birthday Thread!
Fri 04/06/2010 03:18:21
Probably late, but happy birthday Jim :D
#18
The Rumpus Room / Re: Happy Birthday Thread!
Sat 10/04/2010 00:04:12
Thanks for all the birthday wishes! (Although over in the other part of the world it's April 10th...but over here I still have 5 more hours so yay!)
#20
Quote from: Lionmonkey on Fri 23/05/2008 13:30:12
This one's AWESOME with capital letters. It's just so good, I watch it over and over. And it's not by me.


Ahhhhhh that was tripy as helllll xD
SMF spam blocked by CleanTalk