• What Do You Need Help With? V6
    7,544 replies, posted
Hi! I've learned a fair amount of Java, and I want to try and expand my language capabilities, maybe learn a new language. I'm looking at C#. I'm currently running a Windows 8 machine, and a Xubuntu Laptop. I want to be able to develop on both platforms, but from what I've heard, it's pretty difficult if you want to do things like games. I know there's mono for Linux. Again, I'm VERY unintelligent on this topic. Any help here? I know there's not a concrete question in this post, but just a general overview would help me. THank you :) :D
[QUOTE=RoflKawpter;43165503]Hi! I've learned a fair amount of Java, and I want to try and expand my language capabilities, maybe learn a new language. I'm looking at C#. I'm currently running a Windows 8 machine, and a Xubuntu Laptop. I want to be able to develop on both platforms, but from what I've heard, it's pretty difficult if you want to do things like games. I know there's mono for Linux. Again, I'm VERY unintelligent on this topic. Any help here? I know there's not a concrete question in this post, but just a general overview would help me. THank you :) :D[/QUOTE] It's probably not too difficult, but you need to make sure to only use platform independent libraries. If you use plain OpenGL/OpenTK and don't do anything obviously platform specific, you can be pretty sure it will run on both. You can also develop against Mono on Windows if you don't reference Microsofts framework. (There's a check box for not referencing mscorlib.dll somewhere.) If you want to use MonoGame, there's a fork somewhere that does cross-platform properly. I haven't used game frameworks enough to make a recommendation though.
i asked this question a bit ago but i need it reexplained in careful detail because i'm dumb. :< how do i do (AABB?) collision detection in a platformer? like if our world is constructed of tiles on a grid but the player can move free of the grid. so if the player's position + velocity will intersect with a solid block, then what? do i just set the player's velocity to 0 based on where they're coming from? do i correct the intersection so they're just outside the block with magical maths? i feel kind of confused and lost.
Guy and gals, what would be the best way of generating a continuous curve that passes through certain and arbitrary number of points in the order the points are added? I was thinking of using splines, but while it fulfills the criteria for creating a continuous curve, the curve is not produced in the order the points are added. I guess a diagram would work best to explain what I mean, but I can't create one right now so I'll try to explain it: Assuming you have three points A(5.0, 10.0), B(10.0, 25.0), C(30.0, 5.0) I want to generate a smooth and continuous curve between these points, which is easy to do using splines, however I also want to make sure if I add points D(22.0, 45.0) and E(2.0, 30.0) at run-time, the curve to be continuous between C, D and E (in the order added) and not a new curve that passes through all those points (such as E->A->B->D->C). If I were to use multiple splines (ABC and CDE for example) I run into the problem of the curve not being smooth and/or continuous. I am guessing there is a mathematical model or formula that would accomplish what I need, so any information and/or tips pointing me to the right direction would be hugely appreciated. I also thought about using nth degree Bezier curves but then the problem of defining lines and the curve not passing through each defined point arises I think.
[QUOTE=Shotgunz;43167837]i asked this question a bit ago but i need it reexplained in careful detail because i'm dumb. :< how do i do (AABB?) collision detection in a platformer? like if our world is constructed of tiles on a grid but the player can move free of the grid. so if the player's position + velocity will intersect with a solid block, then what? do i just set the player's velocity to 0 based on where they're coming from? do i correct the intersection so they're just outside the block with magical maths? i feel kind of confused and lost.[/QUOTE] You can use [URL="http://blog.sos.gd/controlled-glitch-effect/"]this[/URL] for approximate ceiling and ground collision where gravity hides the error. Otherwise handle x- and y-axis separately, set velocity in that component to 0 on collision and snap to the wall. [editline]edit[/editline] You could also make it a homage to the early Mario games and push the player backwards while they are in a wall, disabling input under the same condition so they don't turn around. The minus world glitch is an exploit of this iirc.
[QUOTE=Fetret;43168220]Guy and gals, what would be the best way of generating a continuous curve that passes through certain and arbitrary number of points in the order the points are added? I was thinking of using splines, but while it fulfills the criteria for creating a continuous curve, the curve is not produced in the order the points are added. I guess a diagram would work best to explain what I mean, but I can't create one right now so I'll try to explain it: Assuming you have three points A(5.0, 10.0), B(10.0, 25.0), C(30.0, 5.0) I want to generate a smooth and continuous curve between these points, which is easy to do using splines, however I also want to make sure if I add points D(22.0, 45.0) and E(2.0, 30.0) at run-time, the curve to be continuous between C, D and E (in the order added) and not a new curve that passes through all those points (such as E->A->B->D->C). If I were to use multiple splines (ABC and CDE for example) I run into the problem of the curve not being smooth and/or continuous. I am guessing there is a mathematical model or formula that would accomplish what I need, so any information and/or tips pointing me to the right direction would be hugely appreciated. I also thought about using nth degree Bezier curves but then the problem of defining lines and the curve not passing through each defined point arises I think.[/QUOTE] Bezier splines. A bezier curve has the nice property that it starts with a derivative that's in the direction of the first line segment (and ends with a derivative in the direction of the last line segment). When appending a point, create e.g. a second-order bezier curve from the last point to the new point. Choose the middle point of the new Bezier spline (if using a 2nd order Bezier spline) arbitrarily from the same line as the previous one. Higher-order Bezier curves can also work, you'll just have to match the last and first segments' directions. I'm not very good at explaining but this pretty picture should be helpful. [img]http://i.imgur.com/BrknTEg.png[/img]
[QUOTE=ThePuska;43170209]Bezier splines. A bezier curve has the nice property that it starts with a derivative that's in the direction of the first line segment (and ends with a derivative in the direction of the last line segment). When appending a point, create e.g. a second-order bezier curve from the last point to the new point. Choose the middle point of the new Bezier spline (if using a 2nd order Bezier spline) arbitrarily from the same line as the previous one. Higher-order Bezier curves can also work, you'll just have to match the last and first segments' directions. [/QUOTE] That worked wonderfully, thank you very much!
[QUOTE=Swebonny;43142980]I marked the typo. The code you gave me initialized i with -1.[/QUOTE] The good news is I got that question correct, I cannot say the same for the rest of the test though. :-P
Hello, I'm working with slick2D to create a test game and right now I'm doing hit detection using rectangles and the intersects method. I created two rectangles for each platform the player comes in contact with; one used to see if the player is hitting the platform from the sides or bottom and another one pixel tall rectangle that is used to see if the character is standing on the platform. The problem is if I add anything that hast to do with a plattop (the one pixel long rectangles) to the update class like say: [code] if(playplathit.intersects(plat1top)) { falling = false; } [/code] when you enter the state that the platforms are in you get this error: Fri Dec 13 22:57:31 EST 2013 ERROR:Game.update() failure - check the game code. org.newdawn.slick.SlickException: Game.update() failure - check the game code. at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:669) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321) at javagame.Game.main(Game.java:34) My guess is that I'm some how overloading Java or Slick. I'm also convinced I'm doing hit detection in the worst possible way as I'm not following a guide. Here is the code without any plattop if statements in the update class: [code] public class Play extends BasicGameState { int[] duration = {200,200}; float playerX = 100; float playerY = 353; float screenX = 0; float screenY = 0; float plat1X = 0; float plat2X = 174; float plat3X = 461; float plat4X = 618; float plat5X = 881; float plat6X = 1233; float plat7X = 1438; float plat8X = 1754; float vertspd = 0.0f; Animation playeranistart, idleani, runforani, runbackani, jumpani; boolean falling; boolean jumping; boolean rightside = false; boolean leftside = false; Rectangle playplathit, plat1, plat2, plat3, plat4, plat5, plat6, plat7, plat8, plat1top, plat2top, plat3top, plat4top, plat5top, plat6top, plat7top, plat8top; public Play(int state) { } public void player() { } public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { Image[] idle = {new Image("res/player.png"), new Image("res/player.png")}; idleani = new Animation(idle,duration,false); Image[] startidle = {new Image("res/player.png"), new Image("res/player.png")}; playeranistart = new Animation(startidle,duration,false); Image[] run1 = {new Image("res/playerrun1.png"), new Image("res/playerrun1.png")}; runforani = new Animation(run1,duration,false); Image[] run2 = {new Image("res/playerrun2.png"), new Image("res/playerrun2.png")}; runbackani = new Animation(run2,duration,false); } public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { Image lvl1 = new Image("res/testlvl.png"); playplathit = new Rectangle(playerX, playerY, 15, 39); plat1 = new Rectangle(plat1X, 393, 597, 8); plat1top = new Rectangle(plat1X, 392, 597, 1); plat2 = new Rectangle(plat2X, 325, 247, 5); plat2top = new Rectangle(plat2X, 324, 247, 1); plat3 = new Rectangle(plat3X, 265, 78, 6); plat3top = new Rectangle(plat3X, 264, 78, 1); plat4 = new Rectangle(plat4X, 232, 141, 5); plat4top = new Rectangle(plat4X, 231, 141, 1); plat5 = new Rectangle(plat5X, 393, 755, 8); plat5top = new Rectangle(plat5X, 392, 755, 1); plat6 = new Rectangle(plat6X, 357, 214, 44); plat6top = new Rectangle(plat6X, 356, 214, 1); plat7 = new Rectangle(plat7X, 330, 219, 70); plat7top = new Rectangle(plat7X, 329, 219, 1); plat8 = new Rectangle(plat8X, 393, 243, 8); plat8top = new Rectangle(plat8X, 392, 243, 1); g.drawImage(lvl1, screenX,screenY); playeranistart.draw(playerX,playerY); g.setColor(Color.red); g.draw(playplathit); g.draw(plat1); g.draw(plat2); g.draw(plat3); g.draw(plat4); g.draw(plat5); g.draw(plat6); g.draw(plat7); g.draw(plat8); g.draw(plat1top); g.draw(plat2top); g.draw(plat3top); g.draw(plat4top); g.draw(plat5top); g.draw(plat6top); g.draw(plat7top); g.draw(plat8top); } public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); if(jumping == false) { vertspd = 0; } if((input.isKeyDown(Input.KEY_D) == false) || (input.isKeyDown(Input.KEY_A) == false)|| (input.isKeyDown(Input.KEY_W) == false)) { playeranistart = idleani; } if(input.isKeyDown(Input.KEY_D)) { screenX = screenX - 3.3f; plat1X = plat1X - 3.3f; plat2X = plat2X - 3.3f; plat3X = plat3X - 3.3f; plat4X = plat4X - 3.3f; plat5X = plat5X - 3.3f; plat6X = plat6X - 3.3f; plat7X = plat7X - 3.3f; plat8X = plat8X - 3.3f; playeranistart = runforani; if(playplathit.intersects(plat1) || playplathit.intersects(plat2) || playplathit.intersects(plat3) || playplathit.intersects(plat4) || playplathit.intersects(plat5) || playplathit.intersects(plat6) || playplathit.intersects(plat7) || playplathit.intersects(plat8)) { if(rightside) { plat1X = plat1X - 3.3f; plat2X = plat2X - 3.3f; plat3X = plat3X - 3.3f; plat4X = plat4X - 3.3f; plat5X = plat5X - 3.3f; plat6X = plat6X - 3.3f; plat7X = plat7X - 3.3f; plat8X = plat8X - 3.3f; screenX = screenX - 3.3f; rightside = false; } else { plat1X = plat1X + 3.3f; plat2X = plat2X + 3.3f; plat3X = plat3X + 3.3f; plat4X = plat4X + 3.3f; plat5X = plat5X + 3.3f; plat6X = plat6X + 3.3f; plat7X = plat7X + 3.3f; plat8X = plat8X + 3.3f; screenX = screenX + 3.3f; leftside = true; } } } if(input.isKeyDown(Input.KEY_A)) { playeranistart = runbackani; plat1X = plat1X + 3.3f; plat2X = plat2X + 3.3f; plat3X = plat3X + 3.3f; plat4X = plat4X + 3.3f; plat5X = plat5X + 3.3f; plat6X = plat6X + 3.3f; plat7X = plat7X + 3.3f; plat8X = plat8X + 3.3f; screenX = screenX + 3.3f; if(playplathit.intersects(plat1) || playplathit.intersects(plat2) || playplathit.intersects(plat3) || playplathit.intersects(plat4) || playplathit.intersects(plat5) || playplathit.intersects(plat6) || playplathit.intersects(plat7) || playplathit.intersects(plat8)) { if(leftside) { plat1X = plat1X + 3.3f; plat2X = plat2X + 3.3f; plat3X = plat3X + 3.3f; plat4X = plat4X + 3.3f; plat5X = plat5X + 3.3f; plat6X = plat6X + 3.3f; plat7X = plat7X + 3.3f; plat8X = plat8X + 3.3f; screenX = screenX + 3.3f; leftside = false; } else { plat1X = plat1X - 3.3f; plat2X = plat2X - 3.3f; plat3X = plat3X - 3.3f; plat4X = plat4X - 3.3f; plat5X = plat5X - 3.3f; plat6X = plat6X - 3.3f; plat7X = plat7X - 3.3f; plat8X = plat8X - 3.3f; screenX = screenX - 3.3f; rightside = true; } } } if(input.isKeyDown(Input.KEY_W)) { if(jumping != true) { vertspd = 1.0f * (delta); playerY = playerY - vertspd; } } } public int getID() { return 1; } } [/code] Thank you for any help.
Made for educational purposes (network programming), it was fun to play with my buddies. However this kind of games should have web-output, but I can't do web at all today. [img]http://i.imgur.com/HpfuMHv.png[/img] [editline]14th December 2013[/editline] fuck miswritten I thought its WAYWO
So i've about had it with fucking around in monogame and half of the content not compiling properly, what would be a good cross platform (Windows/Linux/OSX and web) framework for C# or C++ (that's free and preferably open source, no unity). Don't really mind if it's low level. I looked at OpenTK but that only seems to do Windows/Linux
[QUOTE=Goz3rr;43185292]So i've about had it with fucking around in monogame and half of the content not compiling properly, what would be a good cross platform (Windows/Linux/OSX and web) framework for C# or C++ (that's free and preferably open source, no unity). Don't really mind if it's low level. I looked at OpenTK but that only seems to do Windows/Linux[/QUOTE] Try SDL or SFML, they're both quite portable.
[QUOTE=Goz3rr;43185292]So i've about had it with fucking around in monogame and half of the content not compiling properly, what would be a good cross platform (Windows/Linux/OSX and web) framework for C# or C++ (that's free and preferably open source, no unity). Don't really mind if it's low level. I looked at OpenTK but that only seems to do Windows/Linux[/QUOTE]sfml2.
This is a question so simple it does not deserve a thread on the main dev help forum. Is there a damage type I can inflict a target with that will regenerate over time? Something just [B]like Poison Headcrabs[/B]... It would be great if it even regenerated for NPC's, but I'd have to program that myself I believe. I'm assuming using the Poison damage type will work, but I'm not entirely sure.
[QUOTE=WalkingZombie;43197278]This is a question so simple it does not deserve a thread on the main dev help forum. Is there a damage type I can inflict a target with that will regenerate over time? Something just [B]like Poison Headcrabs[/B]... It would be great if it even regenerated for NPC's, but I'd have to program that myself I believe. I'm assuming using the Poison damage type will work, but I'm not entirely sure.[/QUOTE] I think you're looking for [url=http://facepunch.com/forumdisplay.php?f=65]the GMod Lua scripting section[/url].
[QUOTE=Falcqn;43199744]I think you're looking for [url=http://facepunch.com/forumdisplay.php?f=65]the GMod Lua scripting section[/url].[/QUOTE] No, they don't really have a proper thread I could use to ask a simple question such as this, and I don't want to make an entire new thread just for it!
What would you guys suggest to start learning python from basics ?
[QUOTE=Shotgunz;43187739]sfml2.[/QUOTE] Alright so i decided to use SFML.NET since i'm more comfortable with C#, trying to figure out what the best way to implement a game loop is (since i never had to do that before with monogame) I tried the dewitters one: [code] [DllImport("kernel32.dll")] public static extern long GetTickCount(); private const int SkipTicks = 1000 / 60; private const int MaxFrameskip = 6; private void GameLoop() { Running = true; long nextGameTick = GetTickCount(); while(Running) { int loops = 0; while (GetTickCount() > nextGameTick && loops < MaxFrameskip) { DoUpdate(); nextGameTick += SkipTicks; loops++; } float interpolation = (GetTickCount() + SkipTicks - nextGameTick) / (float)SkipTicks; DoDraw(interpolation); } } [/code] But for some reason my interpolation value is always between 0 and 1, not 1.3 as the example states. Also i'm getting some pretty big fluctuations in updates per second, when set to 60 it'll always be 62-65
GetTickCount can make large jumps and change in speed, also its only precise down to a millisecond. On some computers it only updates every 15ms. Use Stopwatch t = Stopwatch.StartNew(); then use t.Elapsed.TotalMilliseconds
[QUOTE=WalkingZombie;43204641]No, they don't really have a proper thread I could use to ask a simple question such as this, and I don't want to make an entire new thread just for it![/QUOTE] This section of the forum isn't for GLua though. If you want to know how to do something specifically with Garry's Mod Lua (which you seem to be asking) then ask it in that section of the forum. The Programming subforum even has [I]"Forum related to programming languages [B]other than GMod Lua[/B]"[/I] right underneath the link to it. Just make the damned thread in Developer Discussion.
[QUOTE=Felheart;43206019]GetTickCount can make large jumps and change in speed, also its only precise down to a millisecond. On some computers it only updates every 15ms. Use Stopwatch t = Stopwatch.StartNew(); then use t.Elapsed.TotalMilliseconds[/QUOTE] Changed it to that, updates per second is still 62-64. (Also i misread the article interpolation is supposed to be 0-1 so i'll assume that's working right now). Another problem i noticed is that when the fps is really low the interpolation will keep increasing I'm using this to see how often it updates: [code] private readonly Stopwatch _testWatch = new Stopwatch(); private readonly TimeSpan _sample = TimeSpan.FromSeconds(1); private TimeSpan _span; private TimeSpan _prevSpan; private int _updates; protected override void Update() { if(!_testWatch.IsRunning) _testWatch.Start(); _span += _testWatch.Elapsed - _prevSpan; _prevSpan = _testWatch.Elapsed; _updates++; if(_span > _sample) { Console.WriteLine(_updates); _updates = 0; _span -= _sample; } } [/code]
[QUOTE=JDscar;43176866]Hello, I'm working with slick2D to create a test game and right now I'm doing hit detection using rectangles and the intersects method. I created two rectangles for each platform the player comes in contact with; one used to see if the player is hitting the platform from the sides or bottom and another one pixel tall rectangle that is used to see if the character is standing on the platform. The problem is if I add anything that hast to do with a plattop (the one pixel long rectangles) to the update class like say: [code] if(playplathit.intersects(plat1top)) { falling = false; } [/code] when you enter the state that the platforms are in you get this error: Fri Dec 13 22:57:31 EST 2013 ERROR:Game.update() failure - check the game code. org.newdawn.slick.SlickException: Game.update() failure - check the game code. at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:669) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321) at javagame.Game.main(Game.java:34) My guess is that I'm some how overloading Java or Slick. I'm also convinced I'm doing hit detection in the worst possible way as I'm not following a guide. Here is the code without any plattop if statements in the update class: [code] public class Play extends BasicGameState { int[] duration = {200,200}; float playerX = 100; float playerY = 353; float screenX = 0; float screenY = 0; float plat1X = 0; float plat2X = 174; float plat3X = 461; float plat4X = 618; float plat5X = 881; float plat6X = 1233; float plat7X = 1438; float plat8X = 1754; float vertspd = 0.0f; Animation playeranistart, idleani, runforani, runbackani, jumpani; boolean falling; boolean jumping; boolean rightside = false; boolean leftside = false; Rectangle playplathit, plat1, plat2, plat3, plat4, plat5, plat6, plat7, plat8, plat1top, plat2top, plat3top, plat4top, plat5top, plat6top, plat7top, plat8top; public Play(int state) { } public void player() { } public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { Image[] idle = {new Image("res/player.png"), new Image("res/player.png")}; idleani = new Animation(idle,duration,false); Image[] startidle = {new Image("res/player.png"), new Image("res/player.png")}; playeranistart = new Animation(startidle,duration,false); Image[] run1 = {new Image("res/playerrun1.png"), new Image("res/playerrun1.png")}; runforani = new Animation(run1,duration,false); Image[] run2 = {new Image("res/playerrun2.png"), new Image("res/playerrun2.png")}; runbackani = new Animation(run2,duration,false); } public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { Image lvl1 = new Image("res/testlvl.png"); playplathit = new Rectangle(playerX, playerY, 15, 39); plat1 = new Rectangle(plat1X, 393, 597, 8); plat1top = new Rectangle(plat1X, 392, 597, 1); plat2 = new Rectangle(plat2X, 325, 247, 5); plat2top = new Rectangle(plat2X, 324, 247, 1); plat3 = new Rectangle(plat3X, 265, 78, 6); plat3top = new Rectangle(plat3X, 264, 78, 1); plat4 = new Rectangle(plat4X, 232, 141, 5); plat4top = new Rectangle(plat4X, 231, 141, 1); plat5 = new Rectangle(plat5X, 393, 755, 8); plat5top = new Rectangle(plat5X, 392, 755, 1); plat6 = new Rectangle(plat6X, 357, 214, 44); plat6top = new Rectangle(plat6X, 356, 214, 1); plat7 = new Rectangle(plat7X, 330, 219, 70); plat7top = new Rectangle(plat7X, 329, 219, 1); plat8 = new Rectangle(plat8X, 393, 243, 8); plat8top = new Rectangle(plat8X, 392, 243, 1); g.drawImage(lvl1, screenX,screenY); playeranistart.draw(playerX,playerY); g.setColor(Color.red); g.draw(playplathit); g.draw(plat1); g.draw(plat2); g.draw(plat3); g.draw(plat4); g.draw(plat5); g.draw(plat6); g.draw(plat7); g.draw(plat8); g.draw(plat1top); g.draw(plat2top); g.draw(plat3top); g.draw(plat4top); g.draw(plat5top); g.draw(plat6top); g.draw(plat7top); g.draw(plat8top); } public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); if(jumping == false) { vertspd = 0; } if((input.isKeyDown(Input.KEY_D) == false) || (input.isKeyDown(Input.KEY_A) == false)|| (input.isKeyDown(Input.KEY_W) == false)) { playeranistart = idleani; } if(input.isKeyDown(Input.KEY_D)) { screenX = screenX - 3.3f; plat1X = plat1X - 3.3f; plat2X = plat2X - 3.3f; plat3X = plat3X - 3.3f; plat4X = plat4X - 3.3f; plat5X = plat5X - 3.3f; plat6X = plat6X - 3.3f; plat7X = plat7X - 3.3f; plat8X = plat8X - 3.3f; playeranistart = runforani; if(playplathit.intersects(plat1) || playplathit.intersects(plat2) || playplathit.intersects(plat3) || playplathit.intersects(plat4) || playplathit.intersects(plat5) || playplathit.intersects(plat6) || playplathit.intersects(plat7) || playplathit.intersects(plat8)) { if(rightside) { plat1X = plat1X - 3.3f; plat2X = plat2X - 3.3f; plat3X = plat3X - 3.3f; plat4X = plat4X - 3.3f; plat5X = plat5X - 3.3f; plat6X = plat6X - 3.3f; plat7X = plat7X - 3.3f; plat8X = plat8X - 3.3f; screenX = screenX - 3.3f; rightside = false; } else { plat1X = plat1X + 3.3f; plat2X = plat2X + 3.3f; plat3X = plat3X + 3.3f; plat4X = plat4X + 3.3f; plat5X = plat5X + 3.3f; plat6X = plat6X + 3.3f; plat7X = plat7X + 3.3f; plat8X = plat8X + 3.3f; screenX = screenX + 3.3f; leftside = true; } } } if(input.isKeyDown(Input.KEY_A)) { playeranistart = runbackani; plat1X = plat1X + 3.3f; plat2X = plat2X + 3.3f; plat3X = plat3X + 3.3f; plat4X = plat4X + 3.3f; plat5X = plat5X + 3.3f; plat6X = plat6X + 3.3f; plat7X = plat7X + 3.3f; plat8X = plat8X + 3.3f; screenX = screenX + 3.3f; if(playplathit.intersects(plat1) || playplathit.intersects(plat2) || playplathit.intersects(plat3) || playplathit.intersects(plat4) || playplathit.intersects(plat5) || playplathit.intersects(plat6) || playplathit.intersects(plat7) || playplathit.intersects(plat8)) { if(leftside) { plat1X = plat1X + 3.3f; plat2X = plat2X + 3.3f; plat3X = plat3X + 3.3f; plat4X = plat4X + 3.3f; plat5X = plat5X + 3.3f; plat6X = plat6X + 3.3f; plat7X = plat7X + 3.3f; plat8X = plat8X + 3.3f; screenX = screenX + 3.3f; leftside = false; } else { plat1X = plat1X - 3.3f; plat2X = plat2X - 3.3f; plat3X = plat3X - 3.3f; plat4X = plat4X - 3.3f; plat5X = plat5X - 3.3f; plat6X = plat6X - 3.3f; plat7X = plat7X - 3.3f; plat8X = plat8X - 3.3f; screenX = screenX - 3.3f; rightside = true; } } } if(input.isKeyDown(Input.KEY_W)) { if(jumping != true) { vertspd = 1.0f * (delta); playerY = playerY - vertspd; } } } public int getID() { return 1; } } [/code] Thank you for any help.[/QUOTE] Just so if anyone else wanted a fix to a similar problem. I figured out that is instead of a separate hit box for the top of each platform put a hit box o the feet of the player. You can also apply the same concept to the front back and top of the player and get rid of the if(rightside) or if(leftside) part. you just have to make sure the top and bottom hit boxes cant be detected by anything on the side.
-snip- needed to preserve ecx register
I'm trying to decide with a friend of mine what a good framework to work on a 2D platforming game would be. So far we're trying to use Unity but I'm wondering if there's a better alternative out there? I've checked around with LOVE and Game Maker and wondering if any of you would like to weigh in on which is easier, more powerful, etc.
[QUOTE=HellSoldier;43206816]I'm trying to decide with a friend of mine what a good framework to work on a 2D platforming game would be. So far we're trying to use Unity but I'm wondering if there's a better alternative out there? I've checked around with LOVE and Game Maker and wondering if any of you would like to weigh in on which is easier, more powerful, etc.[/QUOTE] The 2d stuff in Unity 4 is really nice. It's up to you really, LOVE is nice too (and 0.9.0 finally came out this week after almost 2 years in development!) but you'll be doing literally everything yourself, whereas with Unity you at least get a way to edit levels and an established workflow out of the box.
[QUOTE=Goz3rr;43206521]Changed it to that, updates per second is still 62-64. (Also i misread the article interpolation is supposed to be 0-1 so i'll assume that's working right now) I'm using this to see how often it updates: [code] private readonly Stopwatch _testWatch = new Stopwatch(); private readonly TimeSpan _sample = TimeSpan.FromSeconds(1); private TimeSpan _span; private TimeSpan _prevSpan; private int _updates; protected override void Update() { if(!_testWatch.IsRunning) _testWatch.Start(); _span += _testWatch.Elapsed - _prevSpan; _prevSpan = _testWatch.Elapsed; _updates++; if(_span > _sample) { Console.WriteLine(_updates); _updates = 0; _span -= _sample; } } [/code][/QUOTE] There is another way of doing things which is not as conventional but it's what I always do now is to Invoke an event every tick and use that in all of your classes, it makes everything very modular. This class is a bit ugly what with the internal helper but it's the best one I have for showing some of the cool stuff you can do. <3 Delegates. [code] using System; using SFML.Graphics; using SFML.Window; namespace Client.Entity { class BaseEntity : Sprite, IClientTemplate { public InternalHelper Helper; public BaseEntity() { Helper = new InternalHelper(this); Client.OnUpdate += Update; Client.OnDraw += Draw; } public virtual void Update() { //Wee, do stuff every frame. } public virtual void Draw() { base.Draw(Client.Window, RenderStates.Default); } public class InternalHelper { private BaseEntity Parent; public InternalHelper(BaseEntity parent) { Parent = parent; } public void Lerp(Vector2f endPosition, int interval) { Vector2f difference = endPosition - Parent.Position; Vector2f direction = difference / interval; int count = 0; Client.ClientHandler delDelegate = null; delDelegate = () => { Parent.Position += direction; count++; if (count >= interval) Client.OnUpdate -= delDelegate; }; Client.OnUpdate += delDelegate; } public bool SeparatingAxisTest(Sprite sprite) { float xDist = System.Math.Abs(sprite.Position.X - Parent.Position.X - sprite.Texture.Size.X/2); float yDist = System.Math.Abs(sprite.Position.Y - Parent.Position.Y - sprite.Texture.Size.Y/2); float calculatedGapX = xDist - sprite.Texture.Size.X / 2; float calculatedGapY = yDist - sprite.Texture.Size.Y / 2; if (calculatedGapX < 0 && calculatedGapY < 0) return true; //Rectangles intersect. else return false; } public void Bezier(Vector2f endPosition, Vector2f controlPoint, int interval) { Vector2f startPos = Parent.Position; double add = 1.0 / interval; float count = 0; Client.ClientHandler delDelegate = null; delDelegate = () => { Parent.Position = (1 - count) * startPos + (2 * (1 - count)) * count * controlPoint + count * endPosition; count += (float)add; if (count >= 1) Client.OnUpdate -= delDelegate; }; Client.OnUpdate += delDelegate; } public void ComplexBezier(Vector2f endPosition, Vector2f controlPointA, Vector2f controlPointB, int interval) { Vector2f startPos = Parent.Position; double add = 1.0 / interval; float count = 0; Client.ClientHandler delDelegate = null; delDelegate = () => { Parent.Position = (1 - count) * startPos + (2 * (1 - count)) * count * controlPointA + count * controlPointB + count * endPosition; count += (float)add; if (count >= 1) Client.OnUpdate -= delDelegate; }; Client.OnUpdate += delDelegate; } } } } [/code]
-snip- Nevermind, it was something stupid.
[QUOTE=koppel;43205265]What would you guys suggest to start learning python from basics ?[/QUOTE] [URL="http://learnpythonthehardway.org/book/"]Learn Python The Hard Way[/URL] is great
I'm using SFML.Net, trying to make a sprite fade out. [code] double alph = Math.Floor((double)255*((maxlife-life)/maxlife)); spr.Color = new Color(255, 255, 255, (byte)alph);[/code] Where maxlife is how long it "lives" for, life is the current counter (starts at 0, goes up to maxlife). This just makes the alpha 0 for some reason, though, when I want it to linearly go from 255-0. Any help? :smile: EDIT: nevermind, needed to cast maxlife and life to doubles first. One day I'll remember you can't just divide ints and expect it to work :v:
-
Sorry, you need to Log In to post a reply to this thread.