I think it is time for me to release all of my functions and stuff I've made, some fo them are large and others are small snippets I use in almost everything!
GetMouse is a function tracking where the player has his/her mouse on the map itself, it does not return any values useable for the screen, atleast it will become very unstable and might not work as you want.
function GetMouseX()
return(GetCameraX()+(((GetMouseScreenX()-(GetScreenWidth()/2)))*GetCameraZoom()))
end
function GetMouseY()
return(GetCameraY()+(((GetMouseScreenY()-GetScreenHeight()/2))*GetCameraZoom()))
end
This code snippet is used in HoveringOverRoid()
DistanceSquared will simplify the use of Pythagoras Theorem, it is very useful as you don't need to do anything much than fill in the arguments values!
function DistanceSquared(x1,y1,x2,y2)
local Xd = x1-x2
local Yd = y1-y2
return((Xd^2)+(Yd^2))
end
This code snippet is used in HoveringOverRoid()
Checks if the player has his/her mouse over a roid, very useful when doing visuals of checking for a click on an asteroid!
function HoveringOverRoid(returntype)
results = nil
for i = 0,1000 do
local checkedroid = GetAsteroid(i)
if checkedroid ~= nil then
if math.sqrt(DistanceSquared(checkedroid.position.x,checkedroid.position.y,GetMouseX(),GetMouseY())) < checkedroid.Radius then
if returntype == "ID" then
results = checkedroid.id
elseif returntype == "Asteroid" then
results = checkedroid
else
results = true
end
break
end
return(results)
end
else
break
end
end
Basically, it returns itself, meaning you can do GetAsteroid(HoveringOverRoid("ID"))
If you have "Asteroid" it gives the GetAsteroid() itself, and ID is... the id of the asteroid and nothing is true/fasle. This might come in very handy :)
Uses Code snippets:
GetMouseX/Y()
DistanceSquared()
Download:
Demo(playable) (http://www.mediafire.com/?owrq5swyu02px91)
Code(unplayable) (http://www.mediafire.com/?kvkeqgh969dr5gv)
DrawText is a very simple and "clean" way to write texts, although it doesn't offer very much fancy things like text type or italic, it is still a very simply handled and clean method of giving players signals on screen or on the level as you desire!
Pictures/Screenshots:
(http://img196.imageshack.us/img196/3279/drawtext.jpg)
Downloads:
Demo(playable) (http://www.mediafire.com/?6bor9e28op3aa4c)
Code(unplayable) (http://www.mediafire.com/?htzctb1v4dot5v8)
Minimap is telling it's own story. It's a small version of either the whole map or what the player has discovered(chosen by the map creator) which will give the player a very nice overview of attacks, weak points or big asteroids! It also supports moving asteroids and size-varying ones too!
Here is some fancy pictures from the randomly generated demo map:
(http://img560.imageshack.us/img560/708/minimap1.jpg)
Here the Minimap isn't magnified, so you can't really see much on the IMAGE! In game it looks fine!
(http://img814.imageshack.us/img814/8923/minimap2.jpg)
Try guess what you see here :)
(http://img28.imageshack.us/img28/575/minimap3.jpg)
Here the first asteroid is being attacked, you can see the amount of seedlings a faction have on an asteroid by the aura shining out!
Added: Customisable Map-Size, Adjustable X/Y(moving the map! NOTE: uses in-game lengths :))
Official Release
Download/Forum Topic: Here (http://www.dyson-game.com/smf/index.php?topic=1402.0)
RingDesigner makes the hassle of setting every single value over and over again MUCH easier, you can make a proper map within minutes, adjusting stats, radius, senddistance, owner, position and treecap! If you can't do it in-game, code snippets on the save if commented to make it lots of easier for you to set a players home or an enemy's base or just and obstacle filled with mines!
The common startup:
(http://img833.imageshack.us/img833/4058/mapcreator1.jpg)
Adding Asteroids:
(http://img64.imageshack.us/img64/1259/mapcreator2.jpg)
Selecting Tools:
(http://img109.imageshack.us/img109/9503/mapcreator3.jpg)
Changing Stats:
(http://img713.imageshack.us/img713/6002/mapcreator4.jpg)
(http://img535.imageshack.us/img535/1153/mapcreator5.jpg)
Changing Owner:
(http://img59.imageshack.us/img59/8626/mapcreator6.jpg)
(http://img37.imageshack.us/img37/5677/mapcreator7.jpg)
Saving:
(http://img28.imageshack.us/img28/1027/mapcreator8.jpg)
Downloads:
Demo(playable) (http://www.mediafire.com/?0g1ure80k10w11b)
Code(unplayable) (http://www.mediafire.com/?5gyqs1nn27izsuy)
Merchant AI is my latest AI(1.8.2011) which is not CPU consumpting at all! if you have 1000 asteroids, it would be exactly the same as having 30, Amount of factions change use of CPU a little, but not much(at all!)!
(http://img199.imageshack.us/img199/9389/mai1u.jpg)
(http://img231.imageshack.us/img231/6838/mai2o.jpg)
(http://img638.imageshack.us/img638/6083/mai3w.jpg)
(http://img692.imageshack.us/img692/8451/mai4e.jpg)
Even at the end, there was no lag!
Downloads:
Demo(playable) (http://www.mediafire.com/?ny2071nqr7izbot)
Code(unplayable) (http://www.mediafire.com/?mxj8n1aa8dg5x3t)
The leaderboard shows all the progress for all the players, their total amount of seedlings, trees and asteroids owned. Together they form the score.
(http://img64.imageshack.us/img64/3587/preview1ftr.jpg)
(http://img820.imageshack.us/img820/6673/preview2o.jpg)
Added leaderboards ;D