tulamide's Recent Forum Activity

  • There's no switch statement in python

    <img src="smileys/smiley9.gif" border="0" align="middle" />

    and "Create" works with a the text name of the object.

    That's what I was looking for.

    from random import randint,random
    
    def edgeplacement(o,l):
       # get the name of the object
       objectName= o.__class__.__name__
    
       if randint(0,1) == 1:
          x = randint(0,1) * 640
          y = random() * 480
       else:
          x = random() * 640
          y = randint(0,1) * 480
       System.Create(objectName,l,x,y)
       getattr(SOL, objectName).angle = random()*360

    Clean and efficient as always! And again something new to learn. Accessing with __class__ is new as is 'getattr' to me. Thank you for sharing it <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Well, the text manipulator method of loading the text does not change anything to the original text file, except that it replaces the newline character with its own newline character. So I would say it depends on how exactly you read in and interpret the text from the editbox. Could you please show a demonstration cap or at least some code snippets?

    I guess you are using 'get token'?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is an issue with the editbox.

    You can workaround it by using the text manipulator object.

    Example:

    + System: Start of layout
    -> TextManipulator: Read file AppPath & "test.txt" line by line
    
    + TextManipulator: On line read
    -> EditBox: Append text TextManipulator.GetReadLine & NewLine
  • * To use random you need to import it prior to using it. It is the best way to import at the beginning of the script:

    import random
    
    def edgeplacement
    ...
    

    * No need for the else-part. You're switching between one of the numbers, that will be generated with randint(1, 4). 'i' will never be set to any other number than 1, 2, 3 or 4.

    * No need to explicitly 'return true'. You may safely delete that line.

    * As far as I know (but I might be wrong), random.random() isn't used as you would like to. It is used without a number in brackets and returns the next random number everytime it is called, which is a number between 0.0 and 1.0

    If I'm right, you better use randint(0, 360) here, or, if you explicitly want decimals, random() * 360

    * You don't reference an object by creating it. You need to access it using SOL (selected objects list). I can't work with CC at the moment, but I think it is something like

    System.Create(o, l, *** yy)

    newobject = SOL.o

    newobject.angle = random.random() * 360

    If SOL doesn't accept a reference, then you need to create the object by name.

  • Whatever one might have in mind regarding Apple, he as a visionary man will leave a big hole.

    I was working with macs, was teaching the use of macs, had a mac myself for more than 10 years and saw Steve Jobs doing so many interesting things. Todays MacOS X wouldn't exist, if he did not found neXt.

    And it is too young to die, no matter if your name is Steve Jobs or any other. 56 just is too young.

  • I use 5-Random(11) for cases like this.

    And it is good that you do so, because random(integer) returns floor(random), or in other words:

    random(10) produces a number greater than 0 and less than 10 (e.g. 0.024 or 9.8453) and returns it rounded down to the nearest integer (0.024 will be returned as 0, 9.8453 as 9)

    As a result, random(10) will return one of 10 numbers ranging from 0 to 9.

    -5 + random(10) would be -5 + [0, 9] => [-5, 4]

    random(10) - 5 would be [0, 9] - 5 => [-5, 4]

    to reach the full range of [-5, 5] (which is 11 numbers) you need random(11) (which returns in a range of 11 numbers from 0 to 10):

    5 - random(11) would be 5 - [0, 10] => [5, -5]

    random(11) - 5 would be [0, 10] - 5 => [-5, 5]

    -5 + random(11) would be -5 + [0, 10] => [-5, 5]

    The order doesn't make a difference, so use whatever looks good to you, just make sure the full range is covered <img src="smileys/smiley1.gif" border="0" align="middle" />

  • There were lots of threads and discussions about this. May search for them if you want to read more about it. It is the simple fact that nothing gets triggered faster than a frame. If a game runs with 60 fps, then the shortest timespan that can be distinguished is 1/60 (ca 16.67 ms)

    So your event is triggered every 16.67ms and only if at that time the timer modulo divided by 7 is 1 the event will actually be executed:

    frame 1 timer = 0 | timer%7 = 0

    frame 2 timer = 16 | timer%7 = 2

    frame 3 timer = 33 | timer%7 = 5

    frame 4 timer = 50 | timer%7 = 1 <-first executed event

    Of course, the hits will raise if in unlimited framerate, because with something like 1000 fps the shortest timespan is 1/1000 = 1 ms, and therefore timer%7 will match 1 much more often.

    Just don't use timespans shorter than the framerate and use a range rather than a definite value (e.g. see it valid if timer%x is lower than 5 or something)

  • <img src="http://img18.imageshack.us/img18/5978/uawesome.jpg" border="0" />

  • So you learned it the hard way, may thank ROJO for recovering at least 192 images, and do backup your files from now on ;) (there even is an auto save and auto backup function in CC, just use them by enabling them in the preferences...)

  • I've corrected the issues and simplified the cap to better see it in action.

    I have to say, you ignored almost every explanation I gave in that post and in the screenshot of the events <img src="smileys/smiley4.gif" border="0" align="middle">

    Never omit brackets when copying events, they serve a purpose: The order of calculations is determined by brackets. Example:

    10 - 4 * 3 = -2

    (10 - 4) * 3 = 18

    I've put them back in.

    The second issue was the missing of an inherited layer with scrollrate and zoomrate set to 0, as mentioned.

    The third issue was a inaccuracy of myself. I didn't show, how the private variable 'pid' is exactly used for the aspect bars.

    In this cap the window is set to 1024x768, while the virtual screen stays at 1920x1080. Your layout size is 1920x1080, too, but you may set it to any size you like.

    F1 switches to fullscreen, F2 switches back to windowed. The fullscreen switch uses the current window size to determine the next best fullscreen size. So it will be 1024x768 fullscreen, presenting a virtual screen of 1920x1080.

    Be aware: This method uses zooming to achieve this. You can't use magicam if you want to use it in your game (magicam also accesses the global zoom, there is currently no relative zoom option in magicam)

    http://www.mediafire.com/file/kmro0jfuzdu3zvh/DynamicScaling.cap

  • Don't know if it is exactly what you mean, but I presented a method some time ago in the old forum that works with a virtual screen. This screen is set to some value (preferably 1920x1080 in your case) and it will always display that 1920x1080, no matter what resolution or ratio the user chooses. Black bars are used on non 16:9 ratios.

    last post in this thread, but the other posts might help as well

  • there's the absolute expression: abs()

    it returns a value without sign (that is: the positive representation)

    abs(-200) = 200

    abs(200) = 200

    ROJO was quicker^^

tulamide's avatar

tulamide

Member since 11 Sep, 2009

Twitter
tulamide has 3 followers

Trophy Case

  • 15-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

17/44
How to earn trophies