|
Post by captainx on Feb 2, 2018 19:29:47 GMT
Hello Everyone, I am new to the Ethanon Engine and enjoying it! I am building a top down science fiction game. The Ethanon Engine seems awesome, but I just don't understand some of the basics yet. I have a few questions: 1. I have an entity that I need to rotate 90 degrees from the top left corner pivot point. I used thisEntity.AddToAngle(1.0f); But it doesn't show the animation. It just instantly moves the graphic immediately 90 degrees even though I am using a loop to call thisEntity.AddToAngle(1.0f); 90 times. How do you animate the graphic's angle so the player can see the entity moving? How do I slow down the motion? 2. I am trying to make a triangle shape “is sensor”. I choose “Polygon” in the Editor and get the warning message that says, “Please save this entity, then setup polygon shape data inside XML <polygon> tags in its file.” Where is this XML file? What do I need to do? I don’t understand what to do? Is it possible to make a triangle "is sensor" ? Does anyone have a sample XML file with tags as an example? 3. I am using a large background image as my environment for the player to explore. This means I need to create invisible entities as walls that sit on top of the background image. This means there could be 100's of invisible entities all over the map, which I cannot see in the scene editor because they are invisible. Is there a better way to select these invisible entities? Is there a better way to create a map with walls without using invisible entities? Help? Thank you, CaptainX
|
|
|
Post by Admin on Feb 3, 2018 14:26:36 GMT
Hi CaptainX, welcome to the almost dead forum. If you can wait till I get sometime later I will definitely give you hand, I am on mobile right now, and not really in a position to answer the questions. This is just a heads up, something to let you know your not being ignored.
|
|
|
Post by Admin on Feb 3, 2018 15:05:35 GMT
Ok so for 1.
void main() { LoadScene("scenes/scene.esc"); }
// Receives a vector and an angle value in radians and returns the rotated vector vector2 rotate(const vector2 &in p, const float angleRad) { return vector2( p.x * cos(angleRad) + p.y * sin(angleRad), - p.x * sin(angleRad) + p.y * cos(angleRad)); }
// Controls the player void ETHCallback_player(ETHEntity@ thisEntity) { ETHInput@ input = GetInputHandle();
// computes the distance our player must move in order to keep // a speed of 60 pixels per second float speed = UnitsPerSecond(120.0f); float angleSpeed = UnitsPerSecond(160.0f);
vector2 direction(0.0f,-1.0f);
if (input.KeyDown(K_RIGHT)) { thisEntity.AddToAngle(-angleSpeed); }
if (input.KeyDown(K_LEFT)) { thisEntity.AddToAngle(angleSpeed); }
// compute rotation vector and do movement direction = rotate(direction, degreeToRadian(thisEntity.GetAngle()));
if (input.KeyDown(K_UP)) { thisEntity.AddToPositionXY(direction * speed); }
if (input.KeyDown(K_DOWN)) { thisEntity.AddToPositionXY(direction *-speed); } }
2.The XML tags are in the *.ent files you need Sublime Text or notepad+ to read them they are UTF16 Encoded, there is a basic triangle example inside.
3.I don't quite understand your question, are they invisible because thats the way you want them, or because their Z-order is messed up? If you want them invisible you can iterate through them at run time and just make them invisible till you want them to be visible. If that isn't the case check your z-orders in the editor they are probably being drawn behind your background. Also make sure the background is a 'horizontal' entity and walls, players, etc.. are 'vertical' entities.
Let me know if that helped or if I missed something.
|
|
|
Post by captainx on Feb 3, 2018 22:51:05 GMT
Thank you Administrator for answering my questions. Let me respond to you. 1. I solved the speed problem using the float speed = UnitsPerSecond(120.0f);. Thank you! 2. I found the XML tags in the entity file. Thank you! The problem is how do I know what V0, V1, V2 should be? I can't see how big the "on sensor" triangle is since it doesn't show up in the editor. How do I determine V0, V1, V2 ? I tried guessing some values for V0, V1, V2 but so far I am way off. Here is the graphic I want to make "on sensor". The entire graphic triangle needs to be "on sensor". The graphic is supposed to be a camera looking for the player. The camera is meant to turn 90 degrees, then turn back 90 degrees searching the hallway for the player. 3. Let me answer your questions. You asked: "are they invisible because thats the way you want them, or because their Z-order is messed up?" Answer: The wall entities need to be invisible because the wall graphics are part of the background image. The background has all the walls, floor, environment etc. So I wanted to create walls the player could not walk through by placing invisible entities on top of the background. The Z-order is ok. The wall entity is invisible because the PNG for the wall entity is transparent. There is nothing in the PNG file. Is there a way to make a wall entity invisible using code, still act like a wall, and have the wall entity be visible in the Scene Editor as a solid graphic image?
4. In my game I need a timed countdown. Hours, Minutes, Seconds counting down. How would you do a countdown? I looked in the manual and couldn't find anything on timers. Any ideas? Thank you, CaptainX
|
|
|
Post by Admin on Feb 3, 2018 23:32:37 GMT
As for the triangle I personally have 0 knowledge as I have never needed it. Give me till tomorrow I will play with the XML tags and see if I can figure out how it works.
Ok just so I don't have a brain fart here, you have a image where the walls/obstacles are already drawn on the image itself? If that is correct, then you want to create invisible collision masks, so the single image has collision characteristics? I hope that is what you meant. If so just use primitives to draw out where the walls are, leaving them visible while creating your scene, then at your 'onSceneCreated' function just hide them all. thisEntity.Hide(true);
4: float myTimer = GetTime(); Then just do your figuring for the difference between when you reset your timer to how much time has passed on the computer and make your timer.
|
|
|
Post by Admin on Feb 4, 2018 19:42:07 GMT
OK as for the XML I have no idea, you should look over the box2d manual, I think that might help put you in the right spot.
|
|
|
Post by captainx on Feb 4, 2018 19:52:35 GMT
Hello Mr. Administrator,
1. I am using thisEntity.Hide(true); and it works great! Thank you for letting me know about this command. It is perfect for hiding invisible walls so a player cannot walk through the walls shown on the environment map.
You asked, "you have a image where the walls/obstacles are already drawn on the image itself? Correct?"
Answer: Yes, that is correct. The background environment map contains all the walls, obstacles, background, objects, etc. That is why I need an invisible wall solution. thisEntity.Hide is perfect for this!
2. I am now using float myTimer = GetTime(); to create a timer. It works pretty well. Thank you for letting me know about this command.
3. I am learning new things about the Ethanon Engine everyday. It is really an amazing tool and I am having a great time working with it. My biggest challenge coming up soon is to implement A* path finding for the game enemies. I have never done this before so I picked up a book on the subject called, "Programming Game AI By Example". It is a great book on basic game AI, but it is written in C/C++. The discussion of AI concepts is very helpful though. I did some searches for Angel Script A* path finding scripts, but couldn't find anything. Let me know if you have any ideas on where to find A* path finding using Angle script code.
Thank you,
CaptainX
|
|
|
Post by Admin on Feb 4, 2018 20:47:42 GMT
|
|
|
Post by Admin on Feb 6, 2018 13:25:10 GMT
OK so for the polygon shapes, the values are relative to the size you have set for the collision box. So 1.0 = 100% positive values are the right values for X and the bottom values for y. So adversely the negative values are the left values of X and top values of Y. All between the scale of -1.0 to 1.0
Good luck!
|
|
|
Post by captainx on Feb 6, 2018 18:54:07 GMT
Hello Mr. Administrator, Thank you for the code for path finding. I don't understand how to use it, but I will definitely look into it. LOL. I will try not to ask too many questions, but.. 1. I wrote some code to have the player's character turn toward the mouse cursor to aim his gun. However, it seems like checking the position of the mouse cursor and rotating the player entity takes up a lot of processes. I currently check the mouse position in "on scene update". which is probably not a good way to do it. Any suggestions on how to improve efficiency here? Same for player bullets. 2. While we are discussing angles. I noticed that the degrees my player character turns is from 0 to 270, then the degrees change to negative values. That seems kinda weird? Shouldn't a circle be from 0 to 360 degrees? Is there a better way to make the player character face the mouse cursor? How would you do it? Thank you, CaptainX
|
|
|
Post by Admin on Feb 6, 2018 19:22:21 GMT
So basically, I think this is what your after, this gives you 0-360, you should be able to point your character at that.
void main() { LoadScene("scenes/newScene.esc", "NewGame", "MainLoop");
// Prefer setting window properties in the app.enml file SetWindowProperties("Ethanon Engine", 1024, 768, true, true, PF32BIT); }
void NewGame() { SetGravity(vector2(0,0)); }
void MainLoop() { ETHInput @input = GetInputHandle(); if (input.KeyDown(K_ESC)) { Exit(); } const float fpsRate = GetFPSRate(); DrawText(vector2(0,0), "FPS: " + fpsRate, "Verdana20_shadow.fnt", ARGB(250,255,0,0)); }
void ETHCallback_Player(ETHEntity@ thisEntity) { ETHInput @input = GetInputHandle(); vector2 mousePos = input.GetCursorPos(); vector2 charPos2D = thisEntity.GetPositionXY(); vector2 screenSpaceCharPos = charPos2D - GetCameraPos(); const float charCursorRadAngle = getAngle(normalize(screenSpaceCharPos - mousePos)); const float charCursorDegreeAngle = radianToDegree(charCursorRadAngle); thisEntity.SetAngle(charCursorDegreeAngle); //add in a delay if you dont want it instant DrawText(vector2(50,50), "Current Radian: " + charCursorRadAngle, "Verdana20_shadow.fnt", ARGB(250,255,0,0)); DrawText(vector2(50,80), "Current Degree: " + charCursorDegreeAngle, "Verdana20_shadow.fnt", ARGB(250,255,0,0)); }
|
|
|
Post by captainx on Feb 7, 2018 3:25:23 GMT
Hello Mr. Administrator,
Regarding the sprite sheet. How does the Editor know what to look for when I create a 4 x 4 sprite sheet? Is there a special type of spacing I should be including with the sprite sheet? I can see the "witch" sample and all the witches are exactly the same size. Any other tips?
Thank you,
CaptainX
|
|
|
Post by Admin on Feb 7, 2018 3:59:56 GMT
Keep it powers of 2, and yeah the same size. I will have an example maybe tomorrow of the bullet angle, I just have to read up on something, I am sure I know it off hand but it has been awhile.
|
|
|
Post by captainx on Feb 7, 2018 23:33:40 GMT
Here is some code that allows a player's character to shoot at the mouse cursor. Hope this helps somebody! void ETHCallback_shot(ETHEntity@ thisEntity) { ETHEntity @hero = SeekEntity("witch.ent"); ETHInput @input = GetInputHandle(); vector2 cursor = input.GetCursorPos(); //get mouse position vector2 player = hero.GetPositionXY(); //bullet start position vector2 screenSpaceCharPos = player - GetCameraPos(); // new line of code! vector2 movement = cursor - screenSpaceCharPos; vector2 direction = normalize(movement); //normalize vector vector2 bulletposition = direction * 9; //add speed thisEntity.AddToPositionXY(vector2(bulletposition.x,bulletposition.y)); } CaptainX
|
|
|
Post by Admin on Feb 7, 2018 23:51:23 GMT
Yes, that is what I thought, the same basic principal as the player rotation..good job!!
|
|