Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Oluseyi

Member Since 13 May 2001
Offline Last Active Sep 02 2015 08:26 PM

#5245873 Create polyline with triangles

Posted by Oluseyi on 11 August 2015 - 08:03 PM

Hello.

 it is possibly that i write it incorrect and you can't understand me. Here I created image showing what i trying to do:

polyline.jpg

 

I got red dots as polyline points. It is easy to create line through this dots. But i need to create polyline with width so I need to create it using triangles.But when i directly create it using only right vector i got errors on curves. Is there any algoritmic way to find vertex points for green triangles?

 

Ah, I see what you mean. Is this a 2D strip or a full 3D "tube"? I'll tackle the 2D solution now, and then we can extrapolate to 3D as necessary.

 

The key is that the red points define a line through the center of your strip, and that at each joint the red point is the center of a cross-cutting line whose adjacent angle is precisely half the deflection between the segments. So, starting from the left of your diagram and numbering the red points p1, p2, p3 and p4:

  • at p1 there is no previous segment, so our strip's ends are perpendicular to the vector <p2 - p1>;
  • at p2 the cross section is at an angle relative to <p2 - p1> that is precisely half the angle between <p2 - p1> and <p2 - p3>;
  • at p3 we have no next segment, so our strip's ends are again perpendicular to the vector, this tome <p3 - p2>.

Remember that perpendicular lines have slopes that are the negatives of each other.

 

Using the above, you should be able to generate the points in your strip. Be careful in your algorithm to maintain the correct vertex order. I'll check back in a couple of days to see how you made out.




#5245148 Pygame - time and movement issues

Posted by Oluseyi on 08 August 2015 - 03:20 PM

Unfortunately I can't run your demo because PyGame on OS X relies on X11, which I won't install, and my Linux box is temporarily out of commission. Nevertheless, I know what your problem is.
 

I've been trying very hard to get smooth movement using Pygame, but no matter how I try, things always look a bit jiggly.
 
I've read many tutorials about time step and pygame's time module, but it did not help. I would basically like to create pixely, "NES-ish" games and have therefore chosen a fixed time step of about 16 ms (= ca. 60 FPS). I've written a little demo program to test the main loop and see if it runs smooth, but the movement seems to stutter a bit sometimes.

 

In your main loop, you do two things. You update the player position:

        player_pos[0] += player_speed
        player_rect.center = player_pos

and you update the frame time, setting an upper bound on refresh frequency:

        frame_duration = clock.tick(FPS) # 1 frame -> ca. 16 milsecs

The former assumes that frame_duration is constant, so it uses a constant increment for player position. The latter obtains the actual duration of the frame, which the PyGame docs tell us: "Note that this function uses SDL_Delay function which is not accurate on every platform…"

 

Your problem is that you are applying what you think is a constant displacement per constant time, yielding constant velocity, but in actuality your time is variable, making your velocity variable. To smooth it out, normalize your displacement by your actual frame time:

FPS = 60
player_speed = 0.8 # pixels per frame
basis_frame_time = 1.0 / FPS

while 1:
    # ...
    frame_duration = clock.tick(FPS)
    frame_displacement = player_speed * (frame_duration / basis_frame_time)
    player_pos[0] += frame_displacement
    #...

That should do it.




#5244963 Python Keyword Arguments for Config files?

Posted by Oluseyi on 07 August 2015 - 10:04 AM

First off, it's generally bad form to embed print statements inside a function that returns a value. What if I want to call it in a non-console context? Given Python's native tuples, you can return both the constructed object and an error string—or, even better, raise an exception on error.

 

 

But what would be the best way?

 

Anyone know of any other uses for keyword arguments? I have seen a few, but this could be a cool use?

 

 

The general use for keyword arguments is cases where some of them are optional. That way you don't have to provide a bunch of None values for parameters you don't care about.




#5243113 for each in: Pythonic?

Posted by Oluseyi on 27 July 2015 - 11:09 PM

Edit: just to clarify, a list containing multiple, non-polymorphic datatypes is almost impossible to operate on idiomatically. You are forced to either know the exact type and order of each element ahead of time (in which case a tuple would be more appropriate), or fallback to a chain of if insinstance(a, Foo): else: statements, which is just bad software design.


Not exactly. Remember that Python is an aggressive/enthusiastic user of duck typing, so non-polymorphic types that nevertheless expose the same interface can be operated on as a coherent collection.
 
#Python 2.7 is still my system default; i should change that...
L = [(1, 2, 3), "four", [5, 6], {'seven': 8, 'nine': 10, 0: 11}]
for item in L:
    print len(item)  # valid for any sequence type
    print i[0]       # valid for any subscriptable object: implement __getitem__()

I was wondering if each would be good if the list had various data types


Presumably you have aggregated your objects into a list because they are somehow conceptually related. That relationship should inform your naming. Their concrete types are not exactly irrelevant, but by far a secondary concern.


#5243104 Is social networking/PR for everyone?

Posted by Oluseyi on 27 July 2015 - 08:40 PM

I'm... Honestly not sure of how I feel about using social networking for myself as an indie developer. Monthly/weekly blogs and--presuming a large enough community--a forum are two types that I don't think that I'd mind. I have an active Google account, so I could perhaps set up a Youtube channel (although I'm not sure that I'd have enough videos to make it worthwhile). As for Twitter, I'm not sure of what I'd use it for that wouldn't work better in a blog post, with both time and space enough to better express myself. Facebook I'd rather just avoid for the most part, I think.

 

As you point out, a forum is really only practical when you have a large community. Otherwise you end up with a bunch of boards with 11 threads and 2 replies. Social networking is about meeting people where they are, and the very best social networking (IMO) leverages asymmetrical follow graphs. Facebook requires that all users have symmetrical peer "Friend" relationships, and that all brands establish "pages" that users can "like." It's a very constricting model, but if that's where your audience is, that's where you'll want to be.

 

Twitter is more interesting to me, in that a person who doesn't follow you can still interact with you quite robustly, and that you don't have to follow those who follow you—following is subscription, and is wholly independent of publication. One huge advantage is that it's easier to cross-pollinate communities without forcing them into stable peerage, so you can tweet with your professional colleagues at different studios on landmark occasions for them, but keep your feed primarily focused on your own content. In general, people who follow you will appreciate those occasional asides without being inundated by them, effectively growing the ecosystem. This is helpful because, hopefully, your colleagues are doing the same for you.

 

But, again, it's all about finding out where your audience is having conversations and joining them there.




#5243024 Is social networking/PR for everyone?

Posted by Oluseyi on 27 July 2015 - 12:30 PM

"Do I really and truly need to register on Facebook/Twitter/LinkedIn/Etc. to be a successful game developer?"


LinkedIn is for jobs/recruitment. It's useless for building an audience for your games. (I think it's near-useless in general, but that's a whole different story.)

 

My complications are derived from the fact that I'm not a very "social" person. No, I should rephrase this...I'm not an "extrovert".


This is not a useful way to think about social networking. Despite the presence of the word "social," it can very much be business or technical networking if that is your preference. There is no need to share more about yourself than you are inclined to, and if your objective is to promote your games, make the account in the name of your studio. Your studio has no "self" per se to post about—no breakfast to tweetshot, no significant other to publicly break-up with, etc.

But, also, social networking isn't all the hyperbolic extremes that you may see satirized in conventional media. I'd wager that social networking at large falls into three distinct categories: narcissistic self-promotion; interest-based engagement (authors/brands/companies/producers/creators with fans/enthusiasts/peers/readers/followers); and news. Creating social networking accounts to share news of your progress and engage with enthusiasts about your work doesn't require any more extroversion than your posts here on GameDev.

 

…maybe I'm just overestimating the matter.

 

I think so. Relax; you'll be fine! biggrin.png




#5242951 When do I save the buffer data?

Posted by Oluseyi on 27 July 2015 - 06:41 AM

 

Hmm strange, the vote arrows are gone from the posts for me unsure.png.

 
Same here, was going to add to his rep!

 

 
That's because he posted it to the Lounge, where voting is disabled. A moderator will probably move it to a more fitting, technical forum, when the arrows will be re-enabled.




#5242891 Who wants to see a C replacement?

Posted by Oluseyi on 26 July 2015 - 09:48 PM

I haven't written production C++ in nearly 5 years. I've never bothered to learn C++11's differences from C++98. I only write C on the rare occasion when I have to dip below the Objective-C runtime and/or NSObject-derived types with their reference-counted memory management. This is to fully qualify my comments:

 

There is no value in a "very C-like" replacement for C.

 

If you want to displace C as a systems programming language, design a ground-up language that is simply better than C. Better at specifying low-level memory layouts, allocations and deallocations. Better at exposing APIs for code sharing, without mandating that two different files be updated per implementation "module." Better are parse database generation, for superior IDE integration, refactoring, etc. Better at type systems and error checking, and enabling the programming to reason about correctness. Better at isolating state and specifying concurrent behaviors.

 

We're only just starting to see languages that attempt this. All this fixation on pointers and header files is window dressing; that shit ain't changing shit. Design a language for the platforms for the future, with compatibility with the present as a secondary characteristic. Good luck!




#5242880 Breaking out of a nested loop

Posted by Oluseyi on 26 July 2015 - 09:03 PM

 

Python exceptions are not meant to represent exceptional error conditions alone, so it isn't an "abuse." As you point out, sequence iteration is terminated by raising StopIteration. This kind and level of exception usage is key to Python's dynamic, introspective nature.


How so? What is done with exceptions that don't represent an error condition that can't be done with any other construct and is so essential to Python's nature?

 


It is perhaps helpful to think of Python exceptions as "execution interruptions": they are an all-purpose, low-overhead synchronous notification of a change to the state you are presently interrogating. Python is highly dynamic, with deep introspection and meta-class hacking abilities front and center. You can treat objects as dictionaries, iterate over their members and examine the existence of attributes without any special syntax. A uniform means of indicating surface limits, then, is the use of exceptions—and that uniformity is prized in Python, due to the Zen of Python belief that "there should be one, and preferably only one, obvious way to do a thing."

 

Essentially, in Python, exceptions represent any interruption of your routine code, any special cases at all. Bounds limits, zero-division, end of file marker, etc. By virtue of being exceptions rather than explicit stateful return values, they can propagate up the call stack and be handled at the logically convenient place.

 

It's perhaps a little different, but it works really well in practice.




#5242688 Breaking out of a nested loop

Posted by Oluseyi on 25 July 2015 - 04:21 PM

This is apparently common in Python (not just for breaking out of inner loops - iterators throw an exception when they reach the end of the container!), but in C++ I wouldn't recommend this. Even in Python I'm leery of doing this, since as ferrous points out exceptions are supposed to be for exceptional cases meaning abusing exceptions like this dilutes their meaning.

 

Python exceptions are not meant to represent exceptional error conditions alone, so it isn't an "abuse." As you point out, sequence iteration is terminated by raising StopIteration. This kind and level of exception usage is key to Python's dynamic, introspective nature.

 

 

As to the OP's question about breaking out of nested loops, assuming the code can not be refactored into a function a pair of adjacent linear iterations, and your language does not have labeled breaks, just use a goto.

 

(Amusingly, this very topic was covered in this very forum as far back as 2006, with the same conclusions drawn. The more things change…)




#5242315 Double Dragon 2 (NES) - Physics and collision

Posted by Oluseyi on 23 July 2015 - 09:56 PM

The only difference between a 2D and a 2.5D area is whether the ground is a very very thin rectangle (basically just a line) or not. All of the actual logic is identical.

 
This.

 

@Don Polettone:

Figure out the logic for your 2.5D areas, in particular some data-based way to determine whether the character is allowed to walk "into" (up) and "out of" (down) the scene. Once you've done that, realize that the 2D areas are exactly the same, except that the walk surface is only 1 pixel wide, prohibiting your character from walking "into" and "out of" the scene.

 

If you want to be devious, you can allow your characters to walk off ledges by extending the 2D surface into 2.5D, but marking the extended areas as fall-throughs.




#5240834 How do you write this down?

Posted by Oluseyi on 16 July 2015 - 10:56 AM

 

 

[…] how do you solve the while clause?

if( v > 0 )

    while( x < 0 );

else

    whle( x > 0 );

while( abs(x + v) > 0) {
    // blah
}

What on earth are you doing?

 

That seems wrong to me.

v might be positive/negative 10000, while x might be positive/negative 5 -- the actual value of v doesn't matter, just whether it's positive or not.

In the posted code, v is never adjusted, while x is. In my example, the while loop should execute 5 times (given valid signs for x and v), which your abs version would not.

 

 

You're right. I looked at the line x += v > 0 ? -1 : 1 and focused too much on x += v, consequently assuming that v was the increment/decrement on x.




#5240827 Need to make app for ipad without apple products...

Posted by Oluseyi on 16 July 2015 - 10:30 AM

 


So I need to make an app that can create a local database as well as upload to a network database, create trend graphs, create and send pdfs in emails, back and restore, and take down signatures.

 

What on earth were you planning to charge for this?

 

I see a mobile app, a cloud service to interface with the database, offline caching of database request results, synchronisation between cache and remote database service, a cloud service to handle PDF and email creation... Even at its most basic, that's got the be north of $5,000 - likely well on it's way to $10,000.

 

In all likelihood, neither Durakken nor his client probably properly valued the work. People always think software is just some pixels on a screen until properly educated.




#5240823 How do you write this down?

Posted by Oluseyi on 16 July 2015 - 10:25 AM

[…] how do you solve the while clause?

if( v > 0 )

    while( x < 0 );

else

    whle( x > 0 );

while( abs(x + v) > 0) {
    // blah
}

What on earth are you doing?




#5240821 Need to make app for ipad without apple products...

Posted by Oluseyi on 16 July 2015 - 10:19 AM

I agree generally with what you are saying but there are 2 key issues...

 

I has 0 moneys to start with.

The other major issue is while I think I can probably do this I am not 100% certain and since I don't know it would be wrong to ask someone I barely know (just met him yesterday for like 15 minutes) to fork out cash on that basis when he could likely pay the same amount to someone that is 100% to get it done.

 

I personally do not like apple products and have no intentions on ever working with them outside of this so it's somewhat at an impasse as getting a device would cut into the reason for me to do it. ya know?

 

You should pass on the job, then. Find something else that you are equipped to do and passionate about. Don't waste your client's time, or yours.






PARTNERS