Results 1 to 3 of 3

Thread: collision and selection rts question/problem thingy

  1. #1

    Thread Starter
    Member wej42's Avatar
    Join Date
    May 2002
    Location
    Rhode Island, USA
    Posts
    48

    collision and selection rts question/problem thingy

    ok, im makin an rts game (not dx... im not to good in it yet)
    during the code all the people and stuff are Rects
    then i "render" the rects that r on the coordinates of where the screen is on the map
    now in theory, that would work... im just not 100% on how to do it:
    since im drawing everything using transblt on a picture box.. how would i have the prog no when i selected... say a person and which person...

    could i do something like (not exact code,just a ruf outline)
    on pic_click..()
    if mousex and mousey > pics x etc
    blah blah... more if its on the coordinates of ne rect
    then:
    do the stuff
    endif
    end sub

    ok u should get the point, but a few things
    1. i think i would have to loop the part where it goes thru and checks if the mouse is on a rect.. cuz i would have to do like
    do until i > numOfBuildings
    if mousex > blah blah building(i).x then
    etc etc stuff
    end if

    then how would i tell if its being selected.. would i have to make some sort of an index on each thing as i make em?

    and i get an error .. i forgot wut it is now (ill post source n **** later) i think it was an overflow when i tried getting the left or right or nething of a rect and comparing it to the mouses... which doesnt make ne sense...

    neways, ill post the basic source later

    thx in advance
    gl on understanding wut i wrote
    Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML

  2. #2
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    Use a control array, in the click event use the "index" to know which image is which.

    Image1_click(x,...,index)
    image(index).left = image(index).left + 1
    end sub

    that would make the picure you click on move to the left.







    Question: How are you doing your unit pathing?
    Don't pay attention to this signature, it's contradictory.

  3. #3
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    He's using bitblt, not controls... Wej your code should be more like this: If MouseX >= PicRect.Left And MouseX <= PicRect.Right And MouseY >= PicRect.Top And MouseY <= PicRect.Bottom Then MsgBox "It's Selected!!!"

    As to the loop, yes, each building (or unit or whatever) should have an index, since they're all in an array. So, huh... what you have there is ok

    Good luck on your game
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

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