Results 1 to 18 of 18

Thread: [Resolved] Movement Problem

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] Movement Problem

    I'm working on a little project just for fun. I have a circle that moves around randomly and one that is controlled by the user.

    However, I'm having a problem keeping the random one on the picturebox. The code (which is the same for the random one) works fine on the user controlled circle.

    And the random one also...randomly jumps to (0, 0) after moving around a bit. I can't figure out why it's doing that.

    The project thus far is attached. Any help you can give would be most appreciated.

    Edit: Attachment removed until I find out whether or not Jupitermedia will own it if I post it.
    Last edited by The Hobo; Nov 21st, 2002 at 08:00 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Anyone?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Just a stupid little mistake. Your random function returns 1 to 5, when its 5 it never changes newcoord and thus it turns into 0, 0. Change the line:
    VB Code:
    1. iPos = ((Rnd * 4) + 1)
    To:
    VB Code:
    1. iPos = ((Rnd * 3) + 1)
    And everything will work.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Thanks! That fixed the "jumping" problem.

    Do you have any idea why it allows the circle to go off screen?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Another stupid mistake. You are actually telling it to move DOWN when you validate it for up:
    VB Code:
    1. Case 1 'up
    2.       NewCoord.X = cPos(0).X
    3.       NewCoord.Y = cPos(0).Y + 1
    4.        
    5.     Case 2 'down
    6.       NewCoord.X = cPos(0).X
    7.       NewCoord.Y = cPos(0).Y - 1
    Now, to fix this, just switch the -1 and the +1 in the NewCoord.Y = ... line.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Oh. I see. Damn. Thanks, man.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    No prob.. this your first time writing a game in VB (per se)?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Kinda. I wrote a Zelda like game where the character navigated around my school and interacted with teachers and faculty.

    What I'm trying to do now is have an "enemy" of sorts. I want to make it so that if he comes within two squares of you, he'll follow you until he catches up with you, then you'll have to fight him or whatever.

    So I'm just experimenting a bit.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    What I'm doing with it now isn't really cool, though. The black circle just kinda spends all it's time in the bottom-left corner.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I made another game once called 'Creatures.' I even posted an early version of the source code here.

    What I did in that was use rnd() to find a point on the PictureBox, and then have it nagivate there, so it looks as if it's following a path.

    That'd probably be a good thing for me to incorporate here, since the way it is now, it's just a random wandering circle.

    I think I'll give that a try.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    That's cool. My first game was one called 'Slugz' - after buying Creatures 2, I was into the whole intelligent cyberpet thing. So I made these little slugs crawl around, mate, etc. I did that 3 years ago. I was just learning VB and I'm still amazed at how it turned out.

    Here's what I'm doing now: >=)
    Attached Images Attached Images  
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  12. #12

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I just got it to where if the black circle is within 2 squares of you, he'll follow you. Once he catches you, you lose. There's a few bugs that I need to work out, but nothing big.

    I want to try to impliment points for avoiding him and make it so the longer you avoid him, more of them will show up.

    I'll also need to impliment a map pretty soon, which wont be hard since I've already done that with my 'School game' I talked about.

    I'll probably eventually make it so there's a way to fight them if they catch you. Like giving each one health.

    Maybe I'll even add some real graphics and such.

    I didn't plan to take it this far, but I might as well go with it and see what I can accomplish.

    Oh yeah. Did I ever talk to you before about my Creatures game, Sastraxi? I remember someone talking about a game they made, and I think it was called 'Slugz?'
    My evil laugh has a squeak in it.

    kristopherwilson.com

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    What I do, whenever I'm not doing a specific project in my spare time (I count TOW as my work time ), I try for a game of some sort. When I have one routine done, that I am really proud of, I add it. After 3 years this has really built up. I can give you some nice routines if you ever want.

    And yes, I remember someone doing Creatures, and I think I had a Slugz thread. Let me check.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  14. #14
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    No, I never posted it... I would, but its now too buggy and has way too bad coding style to be worth it. But it did use inverse masking, so slugz could be any colour. I thought it was pretty cool
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  15. #15

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Here's where we talked about it almost exactly a year ago: http://www.vbforums.com/showthread.p...hreadid=115723
    My evil laugh has a squeak in it.

    kristopherwilson.com

  16. #16
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yeah, I saw that when I looked for it.

    Ah, the good ol' days. 2001 was both the best and worst year for me....
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  17. #17

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Sastraxi
    Yeah, I saw that when I looked for it.

    Ah, the good ol' days. 2001 was both the best and worst year for me....
    I have the worst memory ever...so I couldn't tell you how 2001 was for me.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  18. #18

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I'm having more problems with this. I've literally been trying to fix it all day. Everything was good until I attempted to add "blocks" or "walls" to it.

    Now once they guy gets stuck, all hell breaks loose Run the code to see what I mean. Just let it go for awhile until it crashes.

    Edit: Okay, found out why it was crashing. I'm going to try to get it to work now.
    Last edited by The Hobo; Nov 10th, 2002 at 11:19 AM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width