Silent Cacophony's Recent Forum Activity

  • I'm not sure what you want to do with the file, still, but I did a bit of experimenting in my PyShell:

    >>> with open("grid.txt") as f:
    	s = f.read()
    	
    
    

    s

    '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 0 0 0 0 0 0 0 0 0 4 4 4 4\n4 4 4 0 0 0 0 0 0 0 0 0 0 0 4 4 4\n4 4 0 0 6 8 8 8 6 8 8 8 6 0 0 4 4\n4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n4 4 0 0 6 4 4 4 4 4 4 4 6 0 0 4 4\n4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n4 4 0 0 6 8 9 7 4 7 9 8 6 0 0 4 4\n4 4 0 0 0 0 0 0 4 0 0 0 0 0 0 4 4\n4 4 4 0 0 0 0 0 4 0 0 0 0 0 4 4 4\n4 4 4 4 0 0 0 0 4 0 0 0 0 4 4 4 4\n4 4 4 4 4 4 0 0 4 0 0 4 4 4 4 4 4\n4 4 4 4 4 4 0 0 4 0 0 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4'

    with open("grid.txt") as f:

    s = f.readlines()

    s

    ['4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 0 0 0 0 0 0 0 0 0 4 4 4 4\n', '4 4 4 0 0 0 0 0 0 0 0 0 0 0 4 4 4\n', '4 4 0 0 6 8 8 8 6 8 8 8 6 0 0 4 4\n', '4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n', '4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n', '4 4 0 0 6 4 4 4 4 4 4 4 6 0 0 4 4\n', '4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n', '4 4 0 0 8 4 4 4 4 4 4 4 8 0 0 4 4\n', '4 4 0 0 6 8 9 7 4 7 9 8 6 0 0 4 4\n', '4 4 0 0 0 0 0 0 4 0 0 0 0 0 0 4 4\n', '4 4 4 0 0 0 0 0 4 0 0 0 0 0 4 4 4\n', '4 4 4 4 0 0 0 0 4 0 0 0 0 4 4 4 4\n', '4 4 4 4 4 4 0 0 4 0 0 4 4 4 4 4 4\n', '4 4 4 4 4 4 0 0 4 0 0 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\n', '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4']

    l1 = []

    > for j in s:

    l1.append([i for i in j if not i.isspace()])

    l1

    [

    ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '0', '0', '0', '0', '0', '0', '0', '0', '0', '4', '4', '4', '4'], ['4', '4', '4', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '4', '4', '4'], ['4', '4', '0', '0', '6', '8', '8', '8', '6', '8', '8', '8', '6', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '6', '4', '4', '4', '4', '4', '4', '4', '6', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '6', '8', '9', '7', '4', '7', '9', '8', '6', '0', '0', '4', '4'], ['4', '4', '0', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '0', '4', '4'], ['4', '4', '4', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '4', '4', '4'], ['4', '4', '4', '4', '0', '0', '0', '0', '4', '0', '0', '0', '0', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '0', '0', '4', '0', '0', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '0', '0', '4', '0', '0', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4']]

    l2 = []

    > for j in s:

    l2.append(j.split())

    l2

    [

    ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '0', '0', '0', '0', '0', '0', '0', '0', '0', '4', '4', '4', '4'], ['4', '4', '4', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '4', '4', '4'], ['4', '4', '0', '0', '6', '8', '8', '8', '6', '8', '8', '8', '6', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '6', '4', '4', '4', '4', '4', '4', '4', '6', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '8', '4', '4', '4', '4', '4', '4', '4', '8', '0', '0', '4', '4'], ['4', '4', '0', '0', '6', '8', '9', '7', '4', '7', '9', '8', '6', '0', '0', '4', '4'], ['4', '4', '0', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '0', '4', '4'], ['4', '4', '4', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '4', '4', '4'], ['4', '4', '4', '4', '0', '0', '0', '0', '4', '0', '0', '0', '0', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '0', '0', '4', '0', '0', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '0', '0', '4', '0', '0', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4'], ['4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4']]

    l3 = []

    > for j in s:

    l3.append([int(i) for i in j if not i.isspace()])

    l3

    [

    [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4], [4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4], [4, 4, 0, 0, 6, 8, 8, 8, 6, 8, 8, 8, 6, 0, 0, 4, 4], [4, 4, 0, 0, 8, 4, 4, 4, 4, 4, 4, 4, 8, 0, 0, 4, 4], [4, 4, 0, 0, 8, 4, 4, 4, 4, 4, 4, 4, 8, 0, 0, 4, 4], [4, 4, 0, 0, 6, 4, 4, 4, 4, 4, 4, 4, 6, 0, 0, 4, 4], [4, 4, 0, 0, 8, 4, 4, 4, 4, 4, 4, 4, 8, 0, 0, 4, 4], [4, 4, 0, 0, 8, 4, 4, 4, 4, 4, 4, 4, 8, 0, 0, 4, 4], [4, 4, 0, 0, 6, 8, 9, 7, 4, 7, 9, 8, 6, 0, 0, 4, 4], [4, 4, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 4, 4], [4, 4, 4, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 4, 4, 4], [4, 4, 4, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 0, 0, 4, 0, 0, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 0, 0, 4, 0, 0, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]][/code:1l52u2pk]

    Assuming that you don't want the spaces in the final data structure, and you want numerical values instead of characters, and that you may want to use Construct's array object, I made a simple .cap that demonstrates how you can load the data file into both a 2D python list and a 2D Construct array.

    http://dl.dropbox.com/u/5868916/grid.zip

    The text file should be in the same folder as the .cap in it's current form, is all.

  • I want to use txt file to make my game level with python

    but I don't now the best way of doing it. can anybody help me out.

    I can't quite figure out what it is that you're wanting from that. Can you be more specific?

    Python has really nice text processing abilities, so it sounds quite feasible.

    Do you want to design levels using a text file, then read it into variables using Python? If so, what format would you use? Graphical representation (like arranging characters in a grid pattern to represent the layout), or descriptive (like an .ini file?)

    What type of level? Top-down (like a dungeon level), or side-view (like a platformer?)

    Or, do you want to use Python to procedurally generate the level, then store it in a text file? The generation would be the hard part there. Storing string variables into text files is pretty easy, though. I have an example of procedural generation using python, here. It would be easy to store the results as a text file in that example.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i have problem with setting up a basic "ON/OFF" switch based on variables. of course - if you now a way to do this other then by variables feel free to enlighten me.

    what i want/need:

    When pressing "F1" i want something to move from one place to another, and when pressing F1 again to go back. imagine it like a UI moving from outside of the screen down vertical into the screen, and then going back. bear in mind its not about X/Y position, but actual sliding from point A to B and from B to A.

    what i used:

    ive set up variable "Switching"

    IF key F1 pressed=>
                If variable =0 : 
                               1. move Object verticaly 150
                               2. Set variable to 1
                                     
                if variable =1:
                              1. move Object verticaly -150
                              2. Set variable to 0[/code:1yfih4yu]
    
    and that should work... but it doesnt. most of the time it goes randmly up and down like it would ignore the chanching variable. is there a way to make so that F1 key will be disabled until the variables switches?
    

    Arima's solution is an elegant one for this case, but it may not apply well to all conditional branching situations that you may come across, so I'll point out another way: ELSE.

    ELSE is a system condition that can be used to make sure that only one of the conditions is true in any tick. You had the logic very close to correct for that case:

    IF key F1 pressed=>
                If variable =0 : 
                               1. move Object verticaly 150
                               2. Set variable to 1
                                     
                ELSE:
                              1. move Object verticaly -150
                              2. Set variable to 0[/code:1yfih4yu]
    
    Also you could extend it to a 3-state or more check in similar fashion:
    
    [code:1yfih4yu]IF key F1 pressed=>
                If variable =0 : 
                               1. move Object verticaly 150
                               2. Set variable to 1
                ELSE
                If variable =1 :
                              1. move Object verticaly -150
                              2. Set variable to 2
                ELSE
                If variable =2 :
                              1. spin Object 360 degrees
                              2. Set variable to 0[/code:1yfih4yu]
  • I've looked at LOGO in the past, but I've never used it for anything. It does look to be a good first step.

    That said, my first programming language was commodore 64 BASIC, and I think it was great for beginning programmers, aside from the prevalence of the much disparaged GOTO statement.

    A slightly more modern basic that I liked, which still has a good following is QBASIC. It is a bit better at relating well to the more modern programming languages. Small Basic looks to be a good modern solution, to me.

    A couple of links I had related to this, that you may want to read:

    http://tedfelix.com/cs4kids/

    http://www.tedfelix.com/qbasic/

    Good luck! I think you have a good idea, there.

  • Hi. First, I'll point out that the normal jump works automatically, by pressing the shift key.

    That said, you can make your custom jump work normally by adding another condition to test if the character is on ground to the the event, like so:

    + MouseKeyboard: On key Up arrow pressed

    + blank_character: is on ground

    -> blank_character: Jump

    That will prevent it from jumping again while it is jumping or falling.

  • + MouseKeyboard: Key Space is down
        + System: Is global variable 'Timestamp' Equal to 0
        -> System: Set global variable 'Timestamp' to Timer
        + System: Else
        -> System: Set global variable 'Duration' to Timer - global('Timestamp')
    
    + MouseKeyboard: On key Space released
    -> System: Set global variable 'Timestamp' to 0
    -> System: Set global variable 'Duration' to 0
    
    + System: Always (every tick)
    -> EditBox: Set text to global('Timestamp') & " : " & global('Duration')[/code:2bb1jypp]
    
    Copied as text from Construct, the above is probably how I'd do it. The indented lines are sub-events. The Editbox was just a simple way to display the variables in real time.
    
    Depending upon your needs, you may not need two variables. The above will need the timestamp to be stored, at least.
    
    You could also use a variation that adds TimeDelta to a duration variable every tick while the key is down, and sets it to zero when released...
  • Hi. The code is original, but the ideas are not. For instance, the 'scoring' system for room placement has surely been done before. I'm unsure if the way that I connect rooms has been done like I have done it. It's just what I came up with when I thought of how I'd do it with Construct, and was originally based upon Construct's easy random picking conditions that were used in the prototype.

    I did do quite a bit of research on roguelikes a few years ago, but never got around to starting one back then. Here are a couple of sites that I would recommend checking out:

    http://roguebasin.roguelikedevelopment. ... =Main_Page

    http://www.roguetemple.com/

    I haven't had time to look this one over much, but it looks quite promising:

    http://pcg.wikidot.com/

    And if you can do newsgroups while avoiding the ridiculous spam, I'd recommend the roguelike development one. Here's Google's version of it (horribly spammed):

    http://groups.google.com/group/rec.game ... ent/topics

    I'll be slowly working on mine and posting new examples as I go, but it seems that I'll never have the time I would like to work on it.

    Good luck!

  • Ach. Recursive functions make my head hurt a bit. Other than that, this is pretty cool

    It took me about 10 minutes of staring at that code to figure out how the imageFont object placement worked... And I had no idea about how SetImageOffset can be used like this. Nice.

    I did notice a problem, though. For some reason, 'imageFont: Destroy' does not seem to be working, and the debugger shows a couple thousand objects by the time the message is fully displayed, and the number keeps quickly rising beyond that.

  • Quite nice! I've got to look into ctypes. I really like the zipped dependencies, too.

    I will surely find use for this. Thanks for sharing.

  • Assuming basic platform behavior, I'd do it something like so:

    + MouseKeyboard: On key Control pressed
    -> Charakter: Spawn object Ammo on layer 1 (image point 1)
        + MouseKeyboard: Key Down arrow is down
        -> Ammo: Rotate 45 degrees toward (Charakter.X, Charakter.Y + 100)
        -> Ammo: Set angle to Charakter.Angle + (Charakter.Angle = 0? 45 : -45)
        + System: Else
        + MouseKeyboard: Key Up arrow is down
        -> Ammo: Rotate 45 degrees toward (Charakter.X, Charakter.Y - 100)
        -> Ammo: Set angle to Charakter.Angle + (Charakter.Angle = 0? -45 : 45)[/code:fcer37nn]
    
    I used two different methods to set the angle there, but one is toggled off. The first just rotates the bullet 45 degrees toward a point above or below the character, and the second uses a [url=http://sourceforge.net/apps/mediawiki/construct/index.php?title=Expressions]conditional expression[/url] to set the angle either + or - 45 degrees from the character's angle.
    
    Here's the simple .cap file (v0.99.96) if the above is not clear: 
    
    [url=http://dl.dropbox.com/u/5868916/angledshot.cap]http://dl.dropbox.com/u/5868916/angledshot.cap[/url]
    
    .
  • I also dislike subforums, in general. They have their place in certain circumstances, but should be used sparingly, I think.

    I think that Ashley's proposed organization sounds fine. The "Your Tutorials & Example files" might get a bit cluttered, but I don't think it would be too bad. It would tend to make a logical grouping for many of the posts in those forums.

  • File -> Preferences.

    It has options for auto-saving, and making auto-backups of normal saves.

    I'm not a big fan of auto-save features, but I'd recommend setting at least 3 auto-backups.

    I keep 5 auto-backups, and routinely increment the version number on the end of the file name when I make a significant addition or change. This results in a lot of backups, but can often come in handy. Even if it's not a corrupted file that screws you, imagine that you tried to make a significant change that doesn't work out well... You can always roll it back to undo your mistake.

Silent Cacophony's avatar

Silent Cacophony

Member since 11 Mar, 2010

None one is following Silent Cacophony yet!

Trophy Case

  • 14-Year Club

Progress

14/44
How to earn trophies