Ask something - We can help.

Started by Stupot, Fri 19/12/2008 20:06:21

Previous topic - Next topic

Nikolas

Thank you CaptainD!

I think that the Budoken SF looks rather nice... I can't download right now, but I will in the next couple of days and give it a go...

m0ds

#1501
Techy/webby q:

So I have a virtual hosting package, I pay so much for say 10gb bandwidth a month. I'd worked on the site a bit and not used much of that up, as it's just loading text and a couple of images. But a couple of days ago I put a video on there (that plays from within the site/storage) and by the next day all 10gb (and some) of bandwidth had been used.

Is that most likely because
a) Of my uploading of it?
b) Of my testing the page/video?
c) Because other people found it and it got a lot of plays?

Anyway of course now I need to buy more or have a better plan. My question is - what uses bandwidth? If the video is hosted on the site and a player on the site allows it to be watched/streamed, that is going to EAT it every time someone plays the video, right? And if the vid is 100mb, then each play will use at least 100mb bandwidth?

Some kind of info for layman would be nice... Just so I know I'm spending my money the right way ;) Thank you!!

Wyz

Probably c) I'd say. Just loading the webpage would be enough since the player is likely to cache it completely. It could also be b) if you tested it really zealously yourself (loading the webpage one hundred times). I don't think players store the video for when you play it the next time so it would download it over and over and over.
Videos (and streaming in general) are bandwidth monsters: if you want to put it up for a large audience you might be better off using a dedicated stream service or uploading it to websites like Youtube or Vimeo.  :)
Life is like an adventure without the pixel hunts.

m0ds

#1503
Thanks for the confirm Wyz. I have a feeling it is because I had loaded them a few times in testing (via the page) and I have no doubt some other people turned up and pressed play also. You're right, it needs to be held elsewhere really (or me buy huge amount of bandwidth). And I guess having one of the lowest options (10gb b/w) is also stupid.

SilverSpook

Didn't quite want to start a thread for this so figure this is a good place to ask:

How much do you think the average Adventure Game player would be willing to read?  As in, how wordy do you think things can get before most would get frustrated?  I have more familiarity with cRPGs, so I'd use something like Planescape: Torment or Arcanum as a "Pretty wordy" game that is more writing centric.  Lots of elaborate description (some multi-page lore-stories), long dialogues, etc., all the time.  Something like Resonance appears to be medium-to-lightly wordy, with mostly short lines and one-sentence or shorter descriptions. Written or electronic documents have longer pieces, of course. 

Is Resonance pretty representative of the adventure gaming scene, do you think?

Ubel

SilverSpook, I think it comes down to pacing and how the text is divided. If you print long paragraphs of text on the screen at once the player is bound to feel overwhelmed. But if the text is paced properly, as it usually is in classic adventure games, it's much less straining for the player. I'm obviously only taking into account the majority of players here, there are of course those who enjoy interactive fiction for instance and so are used to reading loads of text. If you're ok with making a game for that smaller demographic then great, go for it, but I don't think most players nowadays have the patience for it. If your game requires large amounts of written content make sure there are enough pauses and enough variety in the presentation of it.

Cassiebsg

I agree with Pablo, personally I don't care for too much text or long cut scene, as I much prefer to explore the world and solve the puzzles... Too much text, and I might as well read a book, too long cut scenes, then I might as well watch a movie or show on TV...
But that's just my personal view point on this subject, I'm sure there's an audience for every type of game, so you need huge amounts of text, then by all means do it. It's your game after all. ;)
There are those who believe that life here began out there...

LRH

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:

Gurok

#1508
There's no such thing as a formal array in Lua, but you can use a table like an array (untested):

Code: lua

local snowflake = {{}, {}, {}} -- 3 snowflakes

function love.load() -- Not sure which engine you're using
	for index = 1, #snowflake
		snowflake[index].x = 5 -- starting positions
		snowflake[index].y = 5
	end
end

function love.update()
	for index = 1, #snowflake
		snowflake[index].x = snowflake[index].x + math.random(-5, 5)
		snowflake[index].y = snowflake[index].y + 1
	end
end


Tables are used for everything in Lua. Arrays, associative arrays, classes, even switch statements. The key concept here is probably "#snowflake" which gets you the number of items (actually the highest integer index for a table).

Comma is how you separate multiple items in a table definition. Also note that if you just comma separate a list, i.e. {{}, {}, {}}, Lua will automatically number them 1, 2 and 3. It's the equivalent of {[1] = {}, [2] = {}, [3] = {}}. To reference a table value by its key (or indeed access an element inside an array), you use square brackets [].

I've intentionally avoided metatables and classes. If you decide to use a class library (or roll your own), you could get fancy by making a Snowflake class and formalise the snowflake objects. But as you can see, simple snowflake objects that just store x and y are easily accomplished using Lua's flexible table system.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#1509
I think I'll post an example of adding snowflakes to existing array, to complement what Gurok said.
Code: lua

local snowflake_array = {} -- empty array of snowflakes

function create_snowflake(x, y)
    local snowflake = {} -- created snowflake object
    snowflake.x = x
    snowflake.y = y
    return snowflake
end

-- Variant with calling an object "constructor"
function create_lots_of_snowflakes()
    for i = 0, 10, 1 do
        snowflake_array[i] = create_snowflake(math.random(320), math.random(240))
    end
end

-- Same without calling a function
function create_lots_of_snowflakes_2()
    for i = 0, 10, 1 do
        snowflake_array[i] = {} -- make sure an object of index 'i' is created
        snowflake_array[i].x = math.random(320)
        snowflake_array[i].y = math.random(240)
    end
end


I am not very experienced with Lua, so can't tell if that's a good practical use of it. But I used this in number of experimental scripts.

EDIT: lol, fixed C++ comments

LRH

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!

LRH

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.

Crimson Wizard

#1512
Domithan, I think the proper way to iterate existing array is to use Gurok's suggested syntax:
Code: lua

for index = 1, #snowflake

This way you won't need to keep array size in a variable, nor use numeric literals (which is a direct road to code hell).
EDIT: For the same reason I would advise to get screen size from love2d library (forgot how it is done), otherwise if you will decide to change screen resolution once, you'll have to seek through all the code and fix the sizes.


That is, when you create elements, you'll have to specify their number:
Code: lua

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


But when you update them or iterate the whole array for any other reason, you should better use #array_name:
Code: lua

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

LRH

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.

Crimson Wizard

#1514
Quote from: Domithan on Sat 13/09/2014 20:29:41
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.
Yes, now I feel confused, because I do not clearly understand what do you not understand :), so it is difficult for me to decide what to say.

What is the difference between ADDING items in a loop and USING them later?
When you add items, it won't make sense to ask table "how many items are there", because it does not know how many more you want to add. So you have to define the loop length yourself.

But when you are USING existing items (e.g. drawing them), they are already in the table, so you CAN ask table "how many items are there" by using #flake_array.

LRH

#1515
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.

RetroJay

Hi all.

I have a question.
Where has SSH gone?

I tried to download his module 'Pixel-perfect collision detection v1.02' but get the 404 error.
So I decided to try his site but that's not working.
Tried PM-ing him but have received no answer.
Even his avatar is missing (You know, the Scottish Superhero.)

According to his stats he was online today a 06:30.???

Yours.
Jay.

Calin Leafshade

A few comments on the lua thingy:

The proper way to iterate a table is to use an iterator like this:

Code: lua


for k,v in ipairs(snowflakes) do
    --k is the index and v is the object
    v.x = v.x + 1
end



ipairs works by stepping through a table from 1 upwards until it hits null so it wont get properties like myTable.x but will work for tables like { 3, 5, 6, 8 } which are similar to arrays.

If you want to iterate through named items like x, y and so forth you can use pairs instead.

Also, when initializing objects you can do this:

Code: lua

local snowflake = { x = 1, y = 2 }


So to rewrite your code with a bit better Lua form:

Code: lua

snspr = love.graphics.newImage("SPR/snow.png")
flake_array = {}
 
function spawn_flakes()
    for i = 1, 100 do -- lua tables start at 1. Don't force it to start at 0 or weird things will happen with iterators and stuff
        table.insert(flake_array, { x = math.random(800), y = math.random(600) })
    end
end
 
function flake_update(dt)
    for index, flake in ipairs(flake_array) do
        flake.x = flake.x + math.random(-50, 50) * dt
        flake.y = flake.y + 1
        if flake.y >= 600 then
            flake.y = 0
        end
    end
end
 
function flake_draw()
    for index, flake = ipairs(flake_array) do
        love.graphics.draw(snspr, flake.x, flake.y)
    end
end



Baron

Quote from: RetroJay on Mon 15/09/2014 06:58:38
Where has SSH gone?

He's been obsessed with his nation-building campaign lately.... (roll)

RetroJay

Hi Baron.

Oh! I see.(laugh)
Thanks for the information.

Do you, or does anyone else, know where I can obtain the module 'Pixel-perfect collision detection v1.02' please.
I don't know if it will help with what I'm trying to do, but I would like to try it.

Yours.
Jay. 

SMF spam blocked by CleanTalk