Aiming and directional movement trouble in 2d game

Hi!
Im writing my second game now, and am having the same problems as i had on my first game.
When firing a bullet from a weapon i cant make it go in the exact direction i want it to go. On my last game (http://home.online.no/~stefjako) i made the bullet movements manually sort of. Very dirty. But now i use Math.cos and Math.sin to move it:
public void draw(Graphics2D g2)
          g2.setColor(Color.WHITE);
          g2.drawOval(position.x, position.y, 1, 1);
      * Moves bullet!
     public void move()
          double newX = (double)position.x +Math.cos(angrad)*factor;
          double newY = (double)position.y +Math.sin(angrad)*factor;
          position.setLocation(newX, newY);
          factor += speed;
     } Where angrad is the given angle in radians, factor = 1.0 , and speed = 0.1 by default.
This works kindof... But in certain angles the bullet will move straight in one direction for a while, and then suddenly start going in an angle. (sorry for the awful explaining)!
How do u guys usually make movements work nice and feel smooth?
Thanks!

More or less like you do.
If I should make a example of why you have to use some sort of float value to hold the position, try making a game where the "game objects" move less than a pixel/frame.
If you use a int value for storing the position this will mean that it won't move at all because it will never move a whole pixel.
Look at this
If your object have a int x and int y holding it's current position.
x + 0.8 = x because 0.8 will be rounded to 0
y + 0.7 = y and the same here
That's what happens when you use only int values, float values is almost nessecary to store the position in games.

Similar Messages

  • I removed some plugins and i have trouble with online games now

    i don't know which add on or plug in is causing problem

    You need to post a link to the online game site that isn't working so someone can figure out what (plugin?) the site needs to work. Some popular plugins are listed here: [[Popular plugins]]. From your list of plugins, It looks like you already have Java plug-in 1.6.0_23 and 4.0.51204.0 (Silverlight) installed.
    You also need to tell us what happens when you visit the site. (Do you see an error message? Does Firefox crash or hang?)

  • I use AIM and am having trouble adding .mac users

    I have added a friend who is using a .mac account and I am Using AIM the problem is we both show up off-line to each other.

    Hi Paul,
    Welcome to the Apple Discussion Pages.
    Like the others who have poste I would guess first at entering the account name wrong.
    http://www.ralphjohnsuk.dsl.pipex.com/page6.html see the "What you need to do" section.
    You have to select whether a Buddy is a .Mac name or an AIM one, and choose the Accont type accordingly.
    In neither case do you need to add an @mac or any other suffix.
    Ralph

  • Downloaded this game, "Where's My Water 2" and before I can even start it asks for my age but freezes and wont move. I've rebooted, turned off, removed and reinstalled and it still wont work but on all my previous iPhones it worked fine.

    Downloaded this game, "Where's My Water 2" and before I can even start it asks for my age but freezes and wont move. I've rebooted, turned off, removed and reinstalled and it still wont work but on all my previous iPhones it worked fine.

    Sorry if I sound stupid but how do I contact the developer? Where would I find that information?

  • Hi all, Since I updated to Mavericks I am having trouble with Safari showing all the buttons/clickable options, but they are gray and will not work. Specifically, the Trash Can/Delete and the "Move to" folder button simply do not work. Any ideas?

    Hi all, Since I updated to Mavericks I am having trouble with Safari showing all the buttons/clickable options, but they are gray and will not work. Specifically, the Trash Can/Delete and the "Move to" folder button simply do not work. Any ideas?

    Please post a screenshot that shows what you mean. Be careful not to include any private information.
    Start a reply to this message. Click the camera icon in the toolbar of the editing window and select the image file to upload it. You can also include text in the reply.

  • HT204370 I purchase a movie.Sherlock Holmes:A game of shadows.All I get the sound and no picture.

    I just purchase a movie,Sherlock Holmes A Game of Shadows All I get is the sound and no picture.

    HBOGO is the problem. Please see their comments below straight from the HBOGO app under the help section.
    "HBO requires a level of content protection that is not currently supported by AirPlay/Apple Tv. We hope to offer this capability in the future."

  • Movie Maker can't start, graphics card has latest drivers and Direct X10

    Hi, I'm attempting to get Movie Maker to start on a 64 bit notebook which I believe has the correct specs and has latest video card drivers and direct X10 or 11, can't remember. How can I further troubleshoot this?
    Bill

    Hi,
    Have you checked that your PC meets the minimum system requirements here:
    http://explore.live.com/windows-live-essentials-system-requirements ?
    Older graphics cards will often not support some of the newer technologies, even if if they have the latest drivers. Is this your issue?
    Also, You may need to install DirectX 9.0c runtime components if you are running Windows 7. This will add some components necessary for programs that use older versions of DirectX, which includes Windows Live 2011 Photo Gallery and Movie Maker.
    Download the full installer here:
    http://go.microsoft.com/fwlink/?linkid=56511&clcid=0x409
    Spencer
    TechNet Community Support

  • PCSX2 and Vdrift. Just see the game if I move the window

    Hello pals. I think that it's caused by proprietary driver ATI.
    I start the game, nothing happends, just the blank screen. And I move the window, and stay moving it, and the game's working, but, let the window in a place, the game aren't shown
    better with video - game.avi
    https://c7rdgg.bay.livefilestore.com/y1 … oad&psid=1
    Imageshack don't like my video.....
    I think ATI driver problem.
    ===============
    Last edited by ilkyest (2012-08-25 16:03:39)

    Vdrift is not listed as being compatible with PCSX2 so you are probably out of luck http://pcsx2.net/compatibility-list.html?letter=V

  • I downloaded digital hd copies of movies onto my parents' computer and they have a new computer now, and the movies aren't there, even though they have the same apple ID. What do I do to get them to download?

    I downloaded digital hd copies of movies onto my parents' computer and they have a new computer now, and the movies aren't there, even though they have the same apple ID. What do I do to get them to download?
    New computer: Dell, Windows 8.1
    Processor: Intel Core i7-4770 CPU @ 3.40GHz
    64-bit Operating System, x64-based processor
    16 GB RAM
    itunes up-to-date
    Old computer: Dell, Microsoft Windows XP
    Processor: Intel Pentium D CPU @ 2.80GHz
    1 GB RAM
    itunes not up-to-date (updating it isn't really an option)
    I have these movies downloaded on the old computer from digital hd redeemed codes: Fantastic Mr. Fox, Super 98, Thor, Inception, The Hunger Games, and Star Trek Into Darkness. I bought Pirates of the Caribbean: The Curse of the Black Pearl on itunes with money, and that one isn't showing up either. When I search it on itunes to see if I can just re-download it, that isn't an option. I would have to buy it again. Home Sharing isn't what I want because the old computer will not be here forever and it is not connected to wifi.
    It's kind of a lot of movies, and I want them on the new computer.

    im so happy I have a iTunes Card Code absolutely free! I got it at http://linkbitty.com/freeitunes2014

  • ATV3 - I need to enable dolby digital for optical surround sound (netflix and home movies), but when I do this it stops audio coming through TV speakers

    I have a cinema sound receiver connected to Apple TV via optical cable.  When I have dolby digital set to Auto it doesn't come through as dolby digital when watching movies on netflix and iTunes (home movies).
    If I set Dolby Digital to ON it works as expected, but the sound stops working through normal TV speakers (via HDMI).  This is the same for netflix and home movies.
    I tried 16 bit setting, but it made no difference.
    Any advice on how I can get this working - meaning Dolby Digital always on for when I turn my surround sound on and sound through speakers for normal operation?
    Obviously I can change the setting when needed, its just a pain.
    Thanks in advance.

    Hello everyone, 
    here is the friendly and signed driver installation method to enable Dolby Digital Plus in your Encore internal speakers only. This is not an official driver, there is no control panel for Dolby Digital Plus or various sound effects, but tested and has much better and richer surround sound quality as before with factory driver. I guess, this driver tweak can work with any Bay Trail tablet also.
    How can you upgrade Encore sound drivers:
    1. Download signed driver package and extract.
    2. Open Device Manager.
    3. Upgrade your Sound, Video and game controllers
    - Intel SST Audio Device
    - Realtek I2S Audio Codec
    one by one with "Have a disk" method.
    4. Double click enabledolby.reg file and add to your registry.
    5. Restart, and enjoy better sound quality.
    Thanks.
    UPDATE: Official Toshiba Dolby Digital leaked, official driver attached: ToshibaDolby.zip
    - Encore with WimBoot -
    Attachments:
    EncoreDolby.zip ‏310 KB
    ToshibaDolby.zip ‏1310 KB

  • What's the easiest way to create a new VLAN and then move all existing devices to it?

    One of our locations was implemented using VLAN1 as the main (native) VLAN. My goal is to create a new sub-interface on the router and then move all the existing switches (all Layer 2) into the new VLAN, without disrupting the network (and remotely). I am trying to determine the best way to proceed. Thanks.

    I wanted to shed a little more light on the situation. The "new" VLAN has actually been in existence since the network was initially setup. The network runs VTP and the new VLAN already has an interface on the router and already shows up on all the switches when you do a "sh vlan" command. We have about 10 VLANs in all. In reality, I am simply trying to migrate about 8 switches from VLAN1 (which they never should have been on) to the new VLAN. I know that I need to create an interface for the new VLAN on each of the switches and then swap the management IP to that interface. If I could connectly directly into each switch via the console port, this would be a simple task. However, the switches are in extremely remote locations with special circumstances, thus I have no physical access to them. This fact has me a little reluctant to making the changes, as we can't afford any mistakes that would potentially cause network downtime. I am looking for some guidance on exactly the steps to take to achieve my goal. Let's call the new vlan, VLAN2. During testing, I logged into a local switch that was on VLAN1 (that's where it had it's management address). It did have VLAN2-VLAN10 as well, via VTP. I created an interface for VLAN3 on the switch and then accessed it via VLAN3 to swap the main management interface from VLAN1 to VLAN2. The changes took, but I couldn't access it via VLAN2. I am assuming this is because the router still has VLAN1 listed as the native vlan and the VLAN2 IP address is still assigned to VLAN1 on the router. What would be the best way for me to make the required changes on the 8 switches that need swapped, without losing remote access? It wouldn't hurt if the network went down for 5 minutes or less, but we can't have a big outage. Thanks.

  • Can I download to Apple TV in my office next to my iMac and latter move the Apple TV to the room with my HD TV and watch a downloaded movie?

    Can I download the movies in my office into a Apple TV unit and where I have my 27 iMac and latter move the Apple unit to my bedroom and watch the downloaded movie in my HD TV?
    I am presently watching movies in my 27 iMac downloded from itunes but would love to see them in my hd tv.
    Another question would be if i can connect the Apple Tv via the HDMI into my Onkyo hometheater and so i would get the full sound? Or do I have to connect to the hd tv directly?
    Best regards

    If it's a first-gen Apple TV (white box), content is stored locally, on its internal HD.  You sync it with iTunes just like an iPod or iPhone, and the files go where the unit goes.
    If it's an ATV 2 (black box), content is streamed over the network from any connected computers' iTunes libraries.  In that case, it shouldn't matter where in the house it is, as long as it and the target iTunes library are on the same network and set up for Home Sharing.
    As for connecting it to your HDTV or Home Theater, either should work fine, though I believe the HDMI only outputs video, in which case you'll also want to use the Optical output for the audio as well.
    Good luck!

  • HT201272 I spend a considerable amount of time in Asia and am finding the ability to download previous purchases now shown on my iCloud account.  Music appears fine and most movies are OK but I have problems with all music videos included with album purch

    I am finding the ability to download previous purchases now shown on my iCloud account to be difficult.  Music appears fine and most movies are OK but I have problems with all music videos included with album purchases.  Any ideas?

    Phillip_dc wrote:
    Firstly, I purchased my first iPhone a few years ago, since then there have been a lot of apps released, a lot which I downloaded for free, tried and deleted from both my phone and my iTune 'Apps' Panel. What bothers me is when I do get a new iOS device, iPad and/or iPhone 5, and I don't want to just copy the back-up of my current iOS device to the new one, then to get the apps I want I will have to scroll through countless useless 'trash' applications in my purchase history to 'cloud download' the ones I want.
    Just sync the apps you want from your computer. You don't need to redownload them directly on the iPhone Purchased list.
    Will Apple be employing such a feature, a 'permanently delete/un-purchase' feature?
    Dunno.
    Send suggestions here -> http://www.apple.com/feedback/

  • AIM and ichat, video not working

    I have 2 aol email accounts and aim with those. I am a little confused on some things. First I have the free aol email and instant messenger. Nothing is downloaded onto my computer, I just signed up for an email account and set it up in mail and ichat. I keep seeing things about versions of aol, well I don't have a version downloaded.
    Can this be the reason that I can not hear people when they conference to me? They hear and see me, and I see them, just no sound from them.
    A friend of mine has same computer I have, bought his 2 days before I bought mine and he said he's had no problem using his ichat. then last night he started having problems and he said the only thing he did was run permssions repair. Which I had also done. So either the permission repair caused something to change that we can no longer use it or there is something else going on.
    I have a linksys router, I have plug and play enabled, I have also tried enabling ports, there is no firewall. The friend has same setup and he NEVER went in and changed settings on his router, it just instantly worked. We also have the same ISP. No ports are being blocked by them. I have also enabled all ports to see if that would help.
    the other person I can not connect to is another story. I need to get mine up and running before I work on hers. She has a wireless pc, and dsl..I am going to check her setting, aol version, and such once mine is proven to work with someone.
    I also can not use big board games...I get a message that says I am behind a firewall (which I am not), I had also tried same thing with the ports, or it says that I have a translated network address. I am guessing that these problems are linked.
    Another person that is a pc tech suggested I setup static ip for my computer and all that mess, and we tried it and still no fix.
    Someone here suggested changing a setting in quicktime for streamline to be less than 1.5 it was set to 384 (or something) so I left it there.
    Yes, all microphones where turned on..it is built in isight.

    Well, this problem is solved, it took several different posts to get answers that worked.
    But here is what got me up and running.
    First, reason I can not connect to pc friend is because she is using the newest version on aim and she needs to be using 5.9 (tried finding who here told me that to give credit, but I can't find the info)
    I don't know why I can't connect to my mac friend. I may be able to now that I fixed somethings, but he's not been online for me to test it out. However, he was able to chat with other people and then he changed some things and now he's not. So, when he is online again I will go over his setup as well.
    Ichat would have worked with no special configurations for me, right out of the box. However, big bang board games will not let me get online and trying to get that online is where I changed things that prevented ichat from ever working.
    If you are having this problem with linksys or netgear router..just turn on plugnplay in router configurations. It is usually on be default. No need to have ports enabled.
    For you mac firewall, just have it turned on, no special ports being opened.
    I do have bonjour chat checked in settings, but I am told that this does not need to be checked. Do not have apple remote sharing checked.
    I do have 10.4.8 installed, so I did not need to go back to an older version.
    This just boiled down to I turned my firewall off and never thought that would cause me not to be able to chat.

  • Why we will go for Queue delta instead of Unserialized and Direct delta ?

    Hi Experts,
    Why we will go for Queue delta instead of Unserialized and Direct delta ? specify any reasons for that ?
    What happens internally when we use Queue delta , Direct delta ?
    I will allocate points to those who help me in detail. My advance thanks who respond to my query.

    Hi,
    Direct Delta
    With this update mode, extraction data is transferred directly to the BW delta queues every time a document is posted. In this way, each document posted with delta extraction is converted to exactly one LUW in the related BW delta queues. If you are using this method, there is no need to schedule a job at regular intervals to transfer the data to the BW delta queues. On the other hand, the number of LUWs per DataSource increases significantly in the BW delta queues because the deltas of many documents are not summarized into one LUW in the BW delta queues as was previously the case for the V3 update.
    If you are using this update mode, note that you cannot post any documents during delta initialization in an application from the start of the recompilation run in the OLTP until all delta init requests have been successfully updated successfully in BW. Otherwise, data from documents posted in the meantime is irretrievably lost. The restrictions and problems described in relation to the "Serialized V3 update" do not apply to this update method.
    This update method is recommended for the following general criteria:
    a) A maximum of 10,000 document changes (creating, changing or deleting documents) are accrued between two delta extractions for the application in question. A (considerably) larger number of LUWs in the BW delta queue can result in terminations during extraction.
    b) With a future delta initialization, you can ensure that no documents are posted from the start of the recompilation run in R/3 until all delta-init requests have been successfully posted. This applies particularly if, for example, you want to include more organizational units such as another plant or sales organization in the extraction. Stopping the posting of documents always applies to the entire client.
    Queued Delta
    With this update mode, the extraction data for the affected application is compiled in an extraction queue (instead of in the update data) and can be transferred to the BW delta queues by an update collective run, as previously executed during the V3 update.
    Up to 10,000 delta extractions of documents to an LUW in the BW delta queues are cumulated in this way per DataSource, depending on the application.
    If you use this method, it is also necessary to schedule a job to regularly transfer the data to the BW delta queues ("update collective run"). However, you should note that reports delivered using the logistics extract structures Customizing cockpit are used during this scheduling. This scheduling is carried out with the same report which is used when you use the V3 updating (RMBWV311, RMBWV312 or RMBWV313).There is no point in scheduling with the RSM13005 report for this update method since this report only processes V3 update entries. The simplest way to perform scheduling is via the "Job control" function in the logistics extract structures Customizing Cockpit. We recommend that you schedule the job hourly during normal operation - that is, after successful delta initialization.
    In the case of a delta initialization, the document postings of the affected application can be included again after successful execution of the recompilation run in the OLTP (e.g OLI7BW, OLI8BW or OLI9BW), provided that you make sure that the update collective run is not started before all delta Init requests have been successfully updated in the BW.
    In the posting-free phase during the recompilation run in OLTP, you should execute the update collective run once (as before) to make sure that there are no old delta extraction data remaining in the extraction queues when you resume posting of documents.
    Using transaction SMQ1 and the queue names MCEX11, MCEX12 or MCEX13 you can get an overview of the data in the extraction queues.
    If you want to use the functions of the logistics extract structures Customizing cockpit to make changes to the extract structures of an application (for which you selected this update method), you should make absolutely sure that there is no data in the extraction queue before executing these changes in the affected systems. This applies in particular to the transfer of changes to a production system. You can perform a check when the V3 update is already in use in the respective target system using the RMCSBWCC check report.
    In the following cases, the extraction queues should never contain any data:
    - Importing an R/3 Support Package
    - Performing an R/3 upgrade
    For an overview of the data of all extraction queues of the logistics extract structures Customizing Cockpit, use transaction LBWQ. You may also obtain this overview via the "Log queue overview" function in the logistics extract structures Customizing cockpit. Only the extraction queues that currently contain extraction data are displayed in this case.
    The restrictions and problems described in relation to the "Serialized V3 update" do not apply to this update method.
    This update method is recommended for the following general criteria:
    a) More than 10,000 document changes (creating, changing or deleting a document) are performed each day for the application in question.
    b) In future delta initializations, you must reduce the posting-free phase to executing the recompilation run in R/3. The document postings should be included again when the delta Init requests are posted in BW. Of course, the conditions described above for the update collective run must be taken into account.
    Un-serialized V3 Update
    Note: Before PI Release 2002.1 the only update method available was V3 Update. As of PI 2002.1 three new update methods are available because the V3 update could lead to inconsistencies under certain circumstances. As of PI 2003.1 the old V3 update will not be supported anymore.
    With this update mode, the extraction data of the application in question continues to be written to the update tables using a V3 update module and is retained there until the data is read and processed by a collective update run.
    However, unlike the current default values (serialized V3 update); the data is read in the update collective run (without taking the sequence from the update tables into account) and then transferred to the BW delta queues.
    The restrictions and problems described in relation to the "Serialized V3 update" do not apply to this update method since serialized data transfer is never the aim of this update method. However, you should note the following limitation of this update method:
    The extraction data of a document posting, where update terminations occurred in the V2 update, can only be processed by the V3 update when the V2 update has been successfully posted.
    This update method is recommended for the following general criteria:
    a) Due to the design of the data targets in BW and for the particular application in question, it is irrelevant whether or not the extraction data is transferred to BW in exactly the same sequence in which the data was generated in R/3.
    Thanks,
    JituK

Maybe you are looking for