Author Topic: hoho  (Read 22909 times)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
hoho
« on: July 14, 2010, 09:10:40 PM »
Just putting in "OnAsteroidSelected" and "OnMouseLeft/RightClicked"  :o

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #1 on: July 14, 2010, 09:19:55 PM »
If you click on an Asteroid, OnAsteroidSelected(ID) will be called. Otherwise, OnMouseLeftClicked(x,y) will be called on a left mouse click and OnMouseRightClicked(x,y) will be called for a right click. x and y are world coordinates of the mouse cursor.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: hoho
« Reply #2 on: July 14, 2010, 11:52:05 PM »
With coordinates  do you mean of the screen? or of the level map?
Like this? :
Code: [Select]
function LevelLogic()
     OnAsteroidSelected(1 :OnMouseLeftClicked(2000,-8000)
End

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #3 on: July 15, 2010, 12:20:50 AM »
map coords yeah.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #4 on: July 16, 2010, 02:02:38 AM »
Once again, this will open many new possibilities for level design.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #5 on: July 16, 2010, 10:00:29 PM »
Will it? I can't think of many, but then I didn't think of making a gravity engine, so...

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: hoho
« Reply #6 on: July 16, 2010, 10:27:47 PM »
you can without gravity engine
if you have a asteroid that is very far away?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #7 on: July 16, 2010, 10:31:22 PM »
Oh, well, lets see...

You could create a map where clicking on a blank bit of space creates an asteroid there.  :>

You could create a map where clicking on a blank bit of space creates an ever-increasing gravity well at that location, peaking after 10 seconds before subsiding again.  Imagine what that would do in a map like Big Bang :>


You could also create a map where clicking on the background causes the background colour to change.  Why is this useful?  I haven't the slightest idea.  :>  But I'm sure it will come in handy for something !


What else, hmm..   you could have a map where you control a single, uber-tough Laser Mine.  When you click somewhere, the mine's "asteroid" (the one it is orbiting) moves - drifting toward the clicked location - although the player wouldn't see this as it has a radius of 0.  All the player would see is the mine moving about.  :>  You could build an arcade-style see-how-many-seedlings-you-can-flatten level.



Imagination ftw !

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #8 on: July 16, 2010, 11:44:20 PM »
You could build a variation of the comet level where the "lift" asteroid moves to a different location when you click on it.

You could draw your own HUD around an asteroid with clickable buttons... we're not completely there yet but I Can add things like getting the mouse's screen coordinates, getting the screen's size, core mouse down and mouse up events that fire ragardless of what you click on, etc etc

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #9 on: July 17, 2010, 12:27:38 AM »
You could actually build an in-game level designer with the likes of this.

You can use the Draw commands, and the Text Draw commands, to render a menu system.

Then, you can have the game add in mechanics or asteroids simply by letting the player click on stuff.  :>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #10 on: July 17, 2010, 12:35:11 AM »
All we'd need is to be able to save levels.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #11 on: July 17, 2010, 12:51:24 AM »
Oh, this will also mean that designers can make tools like the long-called-for rally point, and use them in their levels.

Upon clicking a button, the script is activated.  The next asteroid the player selects is the rally point, and all their seedlings start drifting towards it (the metric shortest-path system used for Infected AI would work fine for this).  Clicking the button a second time toggles the rallying behaviour off again.

Mihhaelo

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 67
Re: hoho
« Reply #12 on: July 18, 2010, 01:25:45 AM »
Quote
Oh, this will also mean that designers can make tools like the long-called-for rally point, and use them in their levels.

Upon clicking a button, the script is activated.  The next asteroid the player selects is the rally point, and all their seedlings start drifting towards it (the metric shortest-path system used for Infected AI would work fine for this).  Clicking the button a second time toggles the rallying behaviour off again.

Wouldn't it be more accuarte to say "This means i can make a bit of code that does this and the rest of the community can use the template i provide them"  :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #13 on: July 18, 2010, 04:50:25 AM »
Judging by some of the posts lately I would think some designers will be able to start building their own mechanics pretty soon.. :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #14 on: July 18, 2010, 05:45:01 AM »
Working on it. If I see the word 'check' one more time I think I'll scream.


Oh, no, there it is! *AAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHH!!!!!!!!1!!!!!!!1!!11!!!!!!!!!!one!!!!!!*

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #15 on: July 18, 2010, 09:05:49 PM »
Code: [Select]
function OnAsteroidSelected()
 --stuff here
end

Doesn't seem to work. It either does nothing, or crashes the game, depending on what I put in it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #16 on: July 19, 2010, 07:09:30 AM »
That's because he's just putting it in, I think..?  It's not live yet..?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #17 on: July 19, 2010, 05:38:23 PM »
Well, the patch is uploaded, and the list of fixes/new stuff includes it, so I thought it would be working now.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #18 on: July 19, 2010, 07:40:51 PM »
should be

function OnAsteroidSelected(id)
-- where id is the id of the asteroid that was selected
end

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #19 on: July 19, 2010, 07:51:43 PM »
How do I use that for any asteroid, so that it is always called when any asteroid is clicked?

Say I wanted to make a box appear that said "You clicked on asteroid " and then displayed the asteroid's id?

Sniped50

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 97
Re: hoho
« Reply #20 on: July 19, 2010, 08:34:13 PM »
@ Pilchard
Wouldn't that be like:
Code: [Select]
function OnAsteroidSelected(id)

      MessageBox("You have clicked on asteroid "..id.."")
      WaitDialog()
end

I dunno. Maybe I am right, but that's basically how it works.

Isn't it?  :P

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #21 on: July 19, 2010, 08:46:47 PM »
Yeah. so like if you wanted asteroid 13 to do something you'd do

function OnAsteroidClicked(id)
  if id == 13 then
    -- do some funky stuff
  end
end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #22 on: July 19, 2010, 09:34:45 PM »
He means OnAsteroidSelected, not OnAsteroidClicked  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #23 on: July 19, 2010, 10:06:10 PM »
No, OnAsteroidClicked is better for what I want to do. I didn't know that one existed.

So, let me get this straight: OnAsteroidClicked() will be called any time an asteroid is clicked, even if that is the one you last clicked on and you have the planting menu open, OnAsteroidSelected() will be called when you click on an asteroid that has no menu coming from it.

Right or wrong.

Or did you mean that Alex meant OnAsteroidSelected()?

Right, I NEED OnAsteroidClicked(). Well, not NEED, but it would be useful.
« Last Edit: July 19, 2010, 10:26:01 PM by Pilchard123 »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #24 on: July 19, 2010, 11:05:25 PM »
Assuming it was a typo on Alex's part and there aren't two distinct functions, the way I would solve this is with the function OnMouseLeftClicked.  This returns X and Y, which are the coords that the mouse was left-clicked at.
Then you would run a For loop, to check all of the asteroids.
On each asteroid check, use some maths to check if X and Y fall within the bounds of that asteroid - you can calculate this based on the asteroid's coords (x and y) and its radius.

Bit complicated, but it IS possible to do this.  It would mean that every time the mouse is left-clicked somewhere in the level, the code would run, and check if an asteroid was clicked on.  It would not matter if it was already selected.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #25 on: July 19, 2010, 11:19:55 PM »
Yeah, that would work, but I've thought of a better way. Thanks anyway.


I still think that OnAsteroidClicked would still be good.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #26 on: July 19, 2010, 11:32:48 PM »
Yeah, that would work, but I've thought of a better way. Thanks anyway.

Willing to share? :>  I can't think of an easier way so I'd be curious what you've come up with :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #27 on: July 19, 2010, 11:36:10 PM »
Oops. It was kind of ambiguous wasn't it. I meant I've thought of a better way to do what I'm working on. Sorry.

Is there any way of drawing something so that it always has the same position and size on the screen, like it was drawn on the camera lens? And also to check if that something (eg. a square) was clicked on?
« Last Edit: July 19, 2010, 11:40:19 PM by Pilchard123 »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #28 on: July 20, 2010, 12:02:23 AM »
I'll put in some stuff for that.

You could do it by getting the camera's position and then dividing the size of your objects by the camera's zoom - that'd make it the right size and put it relative to the camera. Less than ideal though.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #29 on: July 20, 2010, 12:06:07 AM »
So, draw it as if it was to be relative to the world, then divide lengths and positions by the zoom level of the camera?

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #30 on: July 20, 2010, 12:13:53 AM »
Yeah, think so - give it a go. Might be multiply...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #31 on: July 20, 2010, 12:30:45 AM »
No.  Draw it related to the position of the camera, NOT the world.


So for example if you GetCameraPosition and it is 2000, 2000, you know that is where the camera is looking.

If you want your drawing to appear on the right of the screen, you would make the drawing origin at (X + 5000) / GetCameraZoom, Y / GetCameraZoom

I think that should work.  Let us know if it doesn't.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #32 on: July 20, 2010, 12:44:02 AM »
Code: [Select]
function LevelDraw()
scale = GetCameraZoom()
xpos = GetCameraX()
ypos = GetCameraY()

DrawLine((xpos+5000)/scale, ypos/scale, (xpos+5100)/scale, ypos/scale, 0,0,0,0.99,0,0,0,0.99,3)
end

Doesn't work, nor does multiplying.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #33 on: July 20, 2010, 01:04:28 AM »
It probably does, it's just that your line is 5000 pixels off to the right...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #34 on: July 20, 2010, 01:11:24 AM »
Yeah my bad, 5000 is probably a bit much.  Try something more conservative like 100 I guess.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #35 on: July 20, 2010, 03:53:21 AM »
Here's the correct code, but at the moment the camera returns negative values for its position

Code: [Select]
function LevelDraw()

scale = GetCameraZoom()
xpos = GetCameraX()
ypos = GetCameraY()
x1 = 0
y1 = 0
x2 = 200
y2 = 50
DrawLine(xpos + (x1)*scale, ypos + y1*scale, xpos + (x2)*scale, ypos + (y2)*scale, 0,0,0,0.99,0,0,0,0.99,3*scale)

end

So you will need to do
Code: [Select]
xpos = -GetCameraX()
ypos = -GetCameraY()
until I fix it. Which I have, so in the next update this will be fixed.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #36 on: July 20, 2010, 03:56:27 AM »
But I'll put in screen drawing stuff anyway.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #37 on: July 20, 2010, 04:32:25 AM »
There, it's done. Next update this code will let you draw a filled box on the screen by dragging with the left button:

Code: [Select]

        drag=0
mx=0
my=0

function OnMouseLeftDownScreen(x,y)
drag=1
mx=x
my=y
end

function OnMouseLeftUpScreen() -- can include x,y as parameters here if you need them
drag=0
end

function ScreenDraw()
if drag == 1 then
    mx2=GetMouseScreenX()
    my2=GetMouseScreenY()
DrawBox(9,8,mx,my,mx2,my2,1,1,1,1) -- (texture ID, border, left, top, right, bottom, r, g, b, a)
end
end


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #38 on: July 20, 2010, 04:47:16 AM »
Awesomez :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #39 on: July 20, 2010, 05:04:32 AM »
Yeah, but how do I draw other stuff to the screen, through LUA. Like drawing liens in the world, perhaps DrawLineOnScreen(x1,y1,x2,y2,r1,g1,b1,a1,r2,g2,b2,a2)?

I have everything for a rallypoint system set up, when the next update comes, regardless of that last request. Should have it working as soon as the next patch happens.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #40 on: July 20, 2010, 05:17:32 AM »
If you want to draw stuff on the screen, rather than in the world, use the code in my post above e.g.

Code: [Select]
function LevelDraw()

scale = GetCameraZoom()
xpos = -GetCameraX()
ypos = -GetCameraY()
x1 = 0
y1 = 0
x2 = 200
y2 = 50
DrawLine(xpos + (x1)*scale, ypos + y1*scale, xpos + (x2)*scale, ypos + (y2)*scale, 0,0,0,0.99,0,0,0,0.99,3*scale)

end

will draw a line from 0,0 (screen centre) to 200 pixels to the right and 50 pixels down.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #41 on: July 20, 2010, 05:19:05 AM »
Oh, okay. I could probably do the rallypoint now, but it'll be much better from the next patch. Working on it.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: hoho
« Reply #42 on: July 20, 2010, 05:20:05 AM »
OK. I will probably wait at least a few days to see if there are any other issues with the latest one, and see if anyone comes up with any really cool ideas, and see if I can add a few more of the things people want...

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: hoho
« Reply #43 on: July 20, 2010, 05:31:33 AM »
Wow, Alex, this is what I call (a) responsive developer(s). You guys rock!

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #44 on: July 20, 2010, 06:00:20 AM »
Nearly done, just fixing the button.

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: hoho
« Reply #45 on: July 21, 2010, 02:18:22 PM »
Hey, you guys could make the right click function into a way to use an ability, like say after a cooldown period, you can say call in a laser mine or something at the location where you click, or add a boost to seedlings or asteroid traits or something.

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: hoho
« Reply #46 on: August 03, 2010, 08:47:06 PM »
All we'd need is to be able to save levels.

I was looking through the Programming in Lua guide you linked here and noticed that Lua has an I/O library built into it. I just gave it a quick test and found that you can indeed create, read and write to files in a Eufloria map!

So, who wants to make a Visual Level Editor level? ;D
« Last Edit: August 03, 2010, 11:51:39 PM by dragoonreas »

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: hoho
« Reply #47 on: August 03, 2010, 11:46:55 PM »
haha wow that's awesome I didn't even think of trying that.  Like you could use the left and right click functions to move the asteroids around where ever you want them.  I feel like it would need a custom menu for it though to save and load levels.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #48 on: August 04, 2010, 10:59:13 PM »
The real question is when is someone going to recreate Microsoft Paint in Eufloria!
I want a line draw tool!!

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #49 on: August 05, 2010, 12:13:16 AM »
I want a line draw tool!!

It'd be do-able after the next update, I reckon. Heck, you could do it now, even. It would just be less user friendly.

That's my next project then - a line drawing tool. It's just a small change to the rallypoint code.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: hoho
« Reply #50 on: August 05, 2010, 04:39:34 AM »
I was kidding :P

But hey, it proves a point... ;)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: hoho
« Reply #51 on: August 05, 2010, 05:23:08 AM »
I know, but it's something to do.