• What do you need help with? V. 3.0
    4,884 replies, posted
Ahh, thanks.
[QUOTE=esalaka;33407088]In case you were unaware, there are no templates in C.[/QUOTE] In case you were unaware, there are more programming languages than just C and C++ :v:
[QUOTE=ZeekyHBomb;33414054]In case you were unaware, there are more programming languages than just C and C++ :v:[/QUOTE] Not for me there aren't :saddowns:
What is the best way to capture sound samples from audio, that is currently playing? SFML Audio capture seems borken.
[QUOTE=esalaka;33415101]Not for me there aren't :saddowns:[/QUOTE] Python?
[QUOTE=HeatPipe;33415487]What is the best way to capture sound samples from audio, that is currently playing? SFML Audio capture seems borken.[/QUOTE] Every game I've seen doing this seems to be using the [url=http://www.un4seen.com/bass.html]BASS[/url] audio library to do it.
Why is my keyboardstate not working properly [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace ShootingGame { class Player { Texture2D texture; Vector2 position; public Player(Texture2D Texture, Vector2 Position) { texture = Texture; position = Position; keyboard = Keyboard.GetState(); } public void Update() { if (keyboard.IsKeyDown(Keys.Up)) { position.Y -= 1; Console.WriteLine("lol"); } } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(texture, position, Color.White); } } } [/CODE]
Try [code]using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace ShootingGame { class Player { Texture2D texture; Vector2 position; public Player(Texture2D Texture, Vector2 Position) { texture = Texture; position = Position; } public void Update() { KeyboardState keyboard = Keyboard.GetState(); if (keyboard.IsKeyDown(Keys.Up)) { position.Y -= 1; Console.WriteLine("lol"); } } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(texture, position, Color.White); } } } [/code]
Yep, that fixed it... Why does that happen ?
In your original code, you are getting KeyboardState [B]only [/B]when you create your Player.
Hi guys I am a beginner programmer in Vb2010, how do I stop the images from "flickering" Also how could I make the form scroll to the side as I move the character?
I think KeyboardState has to update each frame instead of one time.
[QUOTE=DesolateGrun;33419630]Hi guys I am a beginner programmer in Vb2010, how do I stop the images from "flickering"[/QUOTE] I'm not sure what you mean but try setting the form's DoubleBuffered property to true.
Learning C++ atm I'm pretty far into it, but now I have to learn about the pointers. They gave me instant motivation loss (or you could say a programming anti-boner). So can anyone explain what is the point of pointers ?
[QUOTE=demoTron;33420679]what is the point of pointers ?[/QUOTE] Pointers are values that contain an address to memory in your computer, where data is stored. Like a street address.
Another super newbie question. Is there some particular reason that a .pyc file is not automatically created when I import and run a module file in python? It's really irritating, because if I want to move the source code .py file to another directory for archiving, I have to import using the archive directory rather than running as is using the .pyc file in the original directory.
[QUOTE=demoTron;33420679]Learning C++ atm I'm pretty far into it, but now I have to learn about the pointers. They gave me instant motivation loss (or you could say a programming anti-boner). So can anyone explain what is the point of pointers ?[/QUOTE] Someone more knowledgeable will probably slap my face and say I'm totally wrong but fuck it it'd mean I would learn something in that case too My understanding of the use of pointers is two-fold - first, accessing objects outside of your own code. While you know every variable name, array, class etc in your own code, you can't say the same about any libraries you are using. Say you're making a simple Windows GDI program - you need to call the Windows API and request a window. That function can't tell you it's internal naming structure even if it wanted - it'd be out of scope and such. You are returned a pointer to the created window - an address in memory where it resides. It can be used just as if you had the actual object reference without needing to know the internal structure of the API you're building on. Secondly, practicality. Say you've got an instance of a class, and you pass that object to a function, which modifies it. (this is opposed to a method of it's own class, just to clarify) When you pass arguments to functions, the function receives a copy - not the original. so if you say modify property "foo" in your object, you've got to return the object again, discard the old one, clean up memory, etc etc. If you send a pointer however, it references the original object. Your function can modify it cleanly and just return a success/fail state - without having to destroy and clean up one instance, replacing it with another. One other thing to note about pointers - you've used them already. Arrays are pointers. (again, I fully welcome anyone to bitchslap me and give a better understanding if I'm off about any of this)
I've been playing with simple platform physics today, however I've got a bit stuck with collisions, which I can't seem to get my head around at all. I've got it working with a bounding box collision, however, this is the problem: [vid]http://puu.sh/9ic0[/vid] Basically, I have no idea how to tell what side of the box the player is colliding with, so I have no way of stopping the player going through the sides, or keeping gravity on when the players hits the sides, and that's what I need help with. I've tried googling around but nothing I find seems to be helping. Nevermind, I'm pretty sure I have what I want now. What I'm doing is checking is the player position in relation to the center of the bounding box. (I have no idea why I didn't think of this, it seems so obvious) Nope. Still can't get this shit to work. It's really fucking hurting my head, I've been fucking with this for hours now. The player will always be left or right of the center, and above or below it, so I still can't tell what side the player is hitting.
Probably a different kind of question than what most of you are used to. What can I do to get in the mood to start programming something, I love programming once I get into it but getting off my ass to start something takes a lot of effort.
[QUOTE=reevezy67;33429622]Probably a different kind of question than what most of you are used to. What can I do to get in the mood to start programming something, I love programming once I get into it but getting off my ass to start something takes a lot of effort.[/QUOTE] Whenever I feel like that I literally just make myself do it anyway. I know I'll enjoy it once I start so it's not TOO hard to get over that first hurdle.
[QUOTE=Chris220;33429894]Whenever I feel like that I literally just make myself do it anyway. I know I'll enjoy it once I start so it's not TOO hard to get over that first hurdle.[/QUOTE] Strict deadlines really help too. I just started on a project for a course, it's due in... 14 hours :v:
Maybe I should hire someone to stand behind me and slap me if I start to slack off.
Is around 3000 elements in an int array alot? (C#) (I have found a way around having that many elements, but I'd still like to know for the future if it's too many)
I've come up with this original idea for a game — a top-down zombie shooter! Jokes aside, I have some questions. I'd like the player to be able to move using WASD and the mouse. For that, I need some way to determine the direction in which the player should look to look towards the mouse and then move in that direction when they press W. To this point, I've only made games by just checking if a button is pressed and then move a specific amount of pixels on the coordinate system, but how would I go about to do this? EDIT: I'm making it in LÖVE.
[QUOTE=theJohn;33433781]I've come up with this original idea for a game — a top-down zombie shooter! Jokes aside, I have some questions. I'd like the player to be able to move using WASD and the mouse. For that, I need some way to determine the direction in which the player should look to look towards the mouse and then move in that direction when they press W. To this point, I've only made games by just checking if a button is pressed and then move a specific amount of pixels on the coordinate system, but how would I go about to do this? EDIT: I'm making it in LÖVE.[/QUOTE] I've never used LÖVE but when player presses W: [code] x += cos(look direction); y += sin(look direction); [/code] Also, I think you need to look into atan2 to determine the direction the player needs to look to face the cursor.
[QUOTE=no-named;33433547]Is around 3000 elements in an int array alot? (C#) (I have found a way around having that many elements, but I'd still like to know for the future if it's too many)[/QUOTE] Well its only 11KB of memory so not really.
[QUOTE=high;33434806]Well its only 11KB of memory so not really.[/QUOTE] Alright, thanks. I also just realized that I did the calculations wrong. It wasn't 3000 elements, it was 1721036800000 elements. According to your numbers, that'd be 6.3 terrabytes of memory. Now I'm glad I found a way around having that many elements.
[QUOTE=no-named;33434426]I've never used LÖVE but when player presses W: [code] x += cos(look direction); y += sin(look direction); [/code] Also, I think you need to look into atan2 to determine the direction the player needs to look to face the cursor.[/QUOTE] [code]if love.keyboard.isDown("w") then player.x = player.x + math.cos(math.atan2(love.mouse.getPosition())) + (player.speed * dt) player.y = player.y + math.sin(math.atan2(love.mouse.getPosition())) + (player.speed * dt) end[/code] It just moves towards the bottom-right corner. Is there something wrong with my implementation? I suck at math.
[QUOTE=theJohn;33435243][code]if love.keyboard.isDown("w") then player.x = player.x + math.cos(math.atan2(love.mouse.getPosition())) + (player.speed * dt) player.y = player.y + math.sin(math.atan2(love.mouse.getPosition())) + (player.speed * dt) end[/code] It just moves towards the bottom-right corner. Is there something wrong with my implementation? I suck at math.[/QUOTE] I forgot that cos() and sin() needs to be multiplied by the player's speed. Also, atan2 should takes 2 arguments, which should be player.x-mouse.x and player.y-mouse.y Unless it's mouse.x-player.x, but yeah. What is dt?
[QUOTE=no-named;33435341]I forgot that cos() and sin() needs to be multiplied by the player's speed. Also, atan2 should takes 2 arguments, which should be player.x-mouse.x and player.y-mouse.y Unless it's mouse.x-player.x, but yeah. What is dt?[/QUOTE] [code]if love.keyboard.isDown("w") then player.x = player.x + math.cos(math.atan2(player.x - love.mouse.getX(), player.y - love.mouse.getY()) + (player.speed * dt)) player.y = player.y + math.sin(math.atan2(player.x - love.mouse.getX(), player.y - love.mouse.getY()) + (player.speed * dt)) end[/code] dt is delta time. It works better now. It moves differently depending on where the mouse is, almost in the opposite direction but not exactly. edit: Tried subtracting the player's position from the mouse's position but that didn't work either.
Sorry, you need to Log In to post a reply to this thread.