RomanCenturion's Forum Posts

  • For anyone interested in making the screen scroll based on mouse position, I made a python alternative.

    #Scrolling
    scrollx = System.globalvar('scrollx')
    scrolly = System.globalvar('scrolly')
    scrollratex = 10
    scrollratey = 10
    if System.MouseX > scrollx + 305:
    	System.ScrollX(scrollx + scrollratex)
    if System.MouseX < scrollx - 305:
    	System.ScrollX(scrollx - scrollratex)
    if System.MouseY > scrolly + 125:
    	if System.MouseY < scrolly + 140:
    		System.ScrollY(scrolly + scrollratey)
    if System.MouseY < scrolly - 230:
    	System.ScrollY(scrolly - scrollratey)[/code:a4lnsttt]
    I'm using it in my game and it works fine so far with two layouts. The reason why I used global variables was because I was unable to find a way to get the scroll position in python. Anyway, I made my own grass background texture for the game! I'll upload the next version once I get a dragbox selection tool added.
  • There are several ways to do this. One way would be to add a global variable and add the condition "global variable generator is equal to yes" to what you already have (probably the best way). Also, you would need to add the action "set global variable generator to no" to the event that destroys your generator. Another way you could do it would be with private variables instead of global variables (this would probably be used for multiple generators). However, the shortest and probably least complicated way(as in least steps) to do it would be to add the inverted condition "generator is inside layout" (you can invert a condition by right clicking on it and selecting "Invert Condition") to what you have(I'm guessing this is the worst since it would probably use more cpu.)

    Good luck!

  • I can tell you how I made it scroll, though it's probably not the best way. Basically, I placed four sprites(invisible on start) in the shapes of rectangles around the edges of the screen on my second layer(note:this was the menu layer, the first layer was the game) and set its scroll x/y rates to 0. I also added another sprite(also invisible on start) and gave it the "Center view on me" attribute. The last object I added was the MouseKeyboard object. Finally, on the event sheet, I placed conditions so that when the mouse was over the sprite on the right side of the screen, the sprite(with the attribute) would move right, etc. If you need any clarification, feel free to ask. Also, I believe most of the steps are described in the Help forums. Though, I don't think the whole process is described there.

    Edit: You'll probably have to limit the movement so that the sprite won't move farther than the screen can move. Something that's not included yet in my game. That's why occasionally it will seem that the sprite isn't moving even though it is, it just moved farther than the screen so it takes a while for it to get back.

    Edit2: As opposed to using a sprite to center the screen on, you can use Scroll x/y, something I wasn't sure how to do at first. Anyway, on the event sheet, have when mouse over right sprite, System: set Scroll to X ScrollX + 10, etc. I'm still working on how to not use sprites on the sides.

    Edit3: I worked it out . Here's the event sheet roughly:

    C:System-Compare: MouseX > ScrollX + 200

    A:System-Scroll to X: ScrollX + 10

    C:System-Compare: MouseX < ScrollX - 200

    A:System-Scroll to X: ScrollX - 10

    C:System-Compare: MouseY > ScrollY + 200

    A:System-Scroll to Y: ScrollY + 10

    C:System-Compare: MouseY < ScrollY - 200

    A:System-Scroll to Y: ScrollY - 10

    The values 200 and 10 should change depending on the size of your application. Also, it probably only works for one layer.

  • Thanks! It may take a while, but as long as I stick with it I can finish it.

  • Basicly, I've started making a game similar to Age of Empires. At first, it's going to be a lot like Age of Empires, but I'll individualize it once I finish setting up the basic game. This is only version 0.01, so obviously there's not much too it yet. Also, before anyone says it, I know the graphics are awful. I'm just starting a thread so that I'll be motivated to complete it.

    All or most versions can be found here:

    http://www.box.net/shared/k1q0rpb89z

    Most recent:

    http://www.box.net/shared/x2ynnfdcsh

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for letting me know about triggered conditions not working in Python. I can probably get around it by putting python as a sub-event to the MouseKeyboard action.

    Also, helpful to know combo parameters.

    Thanks a lot everyone! I can't wait to finish version 0.1 of my game.

  • I have no idea if this will work, but here's a possible solution. I would add a canvas into your application. Then, I would paste the object webcam onto the canvas. I'd use image manipulator next to save it as whatever type you want. I don't have a webcam, so I can't try it out, but it may work. Lol.

  • I was wondering how to use the MouseKeyboard on object clicked event in python. I was able to get this far:

    MouseKeyboard.OnClickObject(left,single,Object)[/code:20m0o9c6]However, "single" isn't the correct syntax. Any idea on what to use instead? Thanks.
  • [quote:2h1rx0he]There shouldn't be any limit to python scripts. I was able to run a 100 line script without any issues.

    [quote:2h1rx0he]I've got a few scripts well longer than that, with no problems.

    I don't know why, but it's just ignoring the lines of script. Your'e probably right about it not being limited though, I switched a few lines around with the same result.

    Thanks for the link Silent Cacophony, it looks helpful.

    Edit:Could someone show a simple way of making and getting information from a dictionary in construct? I'm not doing something right and it's frustrating not being able to figure it out.

    I found out how to do it

    d1{}
    d1[1,1,1] = "Hello"
    d1[1,1,2] = "Bob"
    ...
    Text.SetText(d1[1,1,1] + " " + d1[1,1,2])
    #Sets text of Text to "Hello Bob" without the quotes
    [/code:2h1rx0he]
  • [quote:lhqhdp1s][quote:lhqhdp1s]

    In my game, I use the OID of sprites a lot. However, Construct has for, some reason, given two sprites the same OID. Is this normal?

    It is normal, OID is unique for each object type, so two instances of the same type will have the same OID.

    Sorry, I didn't clarify. They were two different objects, not different instances of the same type. I don't think it could have been a mistake since it worked before, but I'll never know now since I got rid of the OID part of my project and converted it in private variables.

    [quote:lhqhdp1s]You want to use UID, it is unique for each object, so no two objects will ever have the same UID.

    Thanks, I think this will help with an issue I'm having of choosing which instance of the object.

    Edit: Is there a limitation on how many lines of script you can have?

    I got up to 65 and nothing after line 65 gets executed.

  • [quote:2qbexcfc]I'm not exactly sure how you want to create, change and use the values.

    I don't know if this will clear things up, but I'll try to.

    at 1,2,1 value = something
    at 1,2,2 value = something else
    at 2,1,1 value = something else
    etc...
    if object clicked:               #what would this be?
    x = 1
    avar = 3
    if object clicked:
    x = 2
    avar = 3
    etc...
    #y and z would be determined by other factors
    if avar == 3:
    text.SetText(value at x,y,z)
    avar = 2
    [/code:2qbexcfc]
    In my game, I use the OID of sprites a lot. However, Construct has for, some reason, given two sprites the same OID. Is this normal? Also, Construct gives the sprites a different OID each time. Is there a way to influence Construct so that OIDs will be at least different from each other each time? I know a way I can work around this, but I'm just wondering why it did this? On a side note, can OIDs be made so that they're always greater than 0? I've tried Sprite.OID + 1, but it seems to cause bugs.
  • For some reason this way of setting global variables wasn't working.

    System.SetGlobalVar('menunum') = 2[/code:aylto7xh]
    Instead I had to use this.
    [code:aylto7xh]System.SetGlobalVar('menunum',2)[/code:aylto7xh]
    [quote:aylto7xh]#" is how you make a comment in Python, not "//"
    
    ya, I know, I get the comment sign mixed up with other programming languages. I believe "//" is java, right?
    [quote:aylto7xh]you might be able to save sometime by using a dictionary
    
    That's probably a good idea. Could this be used to substitute for an array? I wouldn't be using it to save the game, but it would store values with 3 keys (ex. (x,y,z) or (1,2,1)).
    
    This brings me to my final two questions:
    How do you get the oid of an object using python?
    Is there a place where I could have found this information at?
    
    Edit: Solved oid issue. Instead of object.OID, I used Object.OID.
  • Thanks! There's not a lot of posts about python in the forums which can make it difficult to learn it. Using this should make my list of 40 or more things take less time to make.

  • I'm pretty new to python(completely) and I was wondering how to make an object at the mouse position and if this small script would work. I apologize in advance for all the errors in it. Like I said, I have no experience with python.

    if System.global('action') == "Build":
    	System.global('menunum') = 2
    if System.global('action') == "Gather":
    	System.global('menunum') = 3
    if System.global('action') == "House":
    // how do you create and object at mouse position?
    [/code:k2idk6u4]
  • First of all, it would be easier to determine the problem if you posted a .cap.

    Okay, so I'll try and run through how to make a simple selection and de-selection .cap.

    First create sprites sprite1 and sprite2, box dragbox, and mousekeyboard

    Next, give dragbox the selection box behavior, and sprite1 and sprite2 the RTS behavior

    Thirdly, create the private variable for both sprite1 and sprite2 called selected with the text value "no"

    Then add the following to the event sheet:

    on left clicked on sprite1 -> sprite1: set 'selected'(the private

    variable) to "yes"

    on left clicked on sprite2 -> sprite2: set 'selected'(the private

    variable) to "yes"

    pick all sprite1 in selectionbox | sprite1: set selected to "yes"

    (from dragbox behavior) _____ ->

    pick all sprite2 in selectionbox | sprite2: set selected to "yes"

    (from dragbox behavior)

    on right mouse button clicked -> sprite1: set selected to "no"

    sprite2: set selected to "no"

    on left clicked

    Sprite1: Value 'selected' is -> Sprite1: move to mouse (RTS

    equal to "yes" behavior)

    on left clicked

    Sprite2: Value 'selected' is -> Sprite2: move to mouse (RTS

    equal to "yes" behavior)

    Sorry for the rough formating. Hope it helps.