Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 02:11:08 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsoperation bloodshed
Pages: 1 2 [3] 4 5
Print
Author Topic: operation bloodshed  (Read 16900 times)
Quarry
Level 10
*****


View Profile
« Reply #40 on: September 25, 2013, 12:14:07 PM »

That code is  Crazy Epileptic Crazy Epileptic
Logged
vittorioromeo
Level 2
**



View Profile WWW
« Reply #41 on: September 25, 2013, 12:16:30 PM »

That code is  Crazy Epileptic Crazy Epileptic

Fixed 4u <3


...no more pattern matching required, faster, and can be adapted to any tileset in the shape of the wall tileset easily.
Logged

Udderdude
Level 10
*****


View Profile WWW
« Reply #42 on: September 25, 2013, 12:38:25 PM »

Hmm, any idea on how I could make it clearer that they are destructible?

Don't give it any wall or floor colors, make it's sprite have some empty space between it and the wall, don't make it perfectly square.
Logged
vittorioromeo
Level 2
**



View Profile WWW
« Reply #43 on: September 25, 2013, 02:15:36 PM »

Hmm, any idea on how I could make it clearer that they are destructible?

Don't give it any wall or floor colors, make it's sprite have some empty space between it and the wall, don't make it perfectly square.

I will try that tomorrow.

I've refactored some shitty code and finished my font.
Logged

vittorioromeo
Level 2
**



View Profile WWW
« Reply #44 on: September 26, 2013, 05:38:24 AM »

new video - (wall autotiling, charge particles, raycasting, new gfx)




This video shows:
* wall autotiling: the walls now look "joined"
* charge particles: when an enemy is about to shoot or perform an action, "inverse" charging particles are displayed
* raycasting tests: instead of mindlessly shooting, enemies draw their gun only if they can "see" the player (the player can hide behind walls)
* gfx changes: new font made from scratch and turret has a new tile
Logged

Iso
Level 0
***



View Profile
« Reply #45 on: September 26, 2013, 05:48:44 AM »

Your tile selecting code is still a bit messy and can be improved using bits. Ignore the following if you're happy with what you got, as this is just my 2cents/my approach to dynamic tiles. I was using this for an approach where there was A LOT of possible combinations (a texture atlas for a single tile had at least 64 different versions).



Make a bit mask for possible combinations of a tile, so like 1 = NW, 2 = N, 4 = NE, 8 = E, etc.

Then check all the connected tiles and mark the bit as set if you find a matching tile type.

Now you can just convert the bitmask to an int or something and you have a key for what tile to use.

This means your textures/assets array should be indexed on the corresponding integer value of the bitmask. So your piece that connects to something just to the NW is at 1, a piece that connects just to N is 2, a piece that connects to NW and N is 3, etc.

If you need to take it a step further, let's say some of your tiles share the same texture; you can add a bitmask key to actual key array instead.

This throws out all the nested ifs and allows the texture selection to happen on a single line.

I am terrible at explaining code in words so if you need a demonstration/elaboration let me know.
« Last Edit: September 26, 2013, 06:07:19 AM by Iso » Logged

vittorioromeo
Level 2
**



View Profile WWW
« Reply #46 on: September 26, 2013, 06:05:25 AM »

Your tile selecting code is still messy and can be improved using bits. Ignore the following if you're happy with what you got, as this is just my 2cents/my approach to dynamic tiles. I was using this for an approach where there was A LOT of possible combinations (a texture atlas for a single tile had at least 64 different versions).



Make a bit mask for possible combinations of a tile, so like 1 = NW, 2 = N, 4 = NE, 8 = E, etc.

Then check all the connected tiles and mark the bit as set if you find a matching tile type.

Now you can just convert the bitmask to an int or something and you have a key for what tile to use.

This means your textures/assets array should be indexed on the corresponding integer value of the bitmask. So your piece that connects to something just to the NW is at 1, a piece that connects just to N is 2, a piece that connects to NW and N is 3, etc.

If you need to take it a step further, let's say some of your tiles share the same texture; you can add a bitmask key to actual key array instead.

This throws out all the nested ifs and allows the texture selection to happen on a single line.

I am terrible at explaining code in words so if you need a demonstration/elaboration let me know.

Thanks for the idea!
I just finished implementing it after reading this.

Code is now a 5-liner, but I'm sure it can be improved Smiley

---

Got it down to this:


Can it be improved any further?
« Last Edit: September 26, 2013, 06:13:23 AM by vittorioromeo » Logged

Iso
Level 0
***



View Profile
« Reply #47 on: September 26, 2013, 06:16:12 AM »

Thanks for the idea!
I just finished implementing it after reading this.

Code is now a 5-liner, but I'm sure it can be improved Smiley

Oh man I totally forgot about that tutorial, it was a good starting point for me but I found his explanation confusing. So I ended up doing taking the idea and tweaking it. Good job on implementing it though, it's an awesome little idea.

I dunno if you can cut it down anymore, but it's looking a lot better than the original if monster Tongue
Logged

Quarry
Level 10
*****


View Profile
« Reply #48 on: September 26, 2013, 06:24:44 AM »

That's as short as it can ever get
Logged
vittorioromeo
Level 2
**



View Profile WWW
« Reply #49 on: September 26, 2013, 06:31:33 AM »

That's as short as it can ever get

NO  Evil


....


jk now
Logged

Quarry
Level 10
*****


View Profile
« Reply #50 on: September 26, 2013, 06:48:28 AM »

What language is this!?
Logged
Iso
Level 0
***



View Profile
« Reply #51 on: September 26, 2013, 06:53:19 AM »



If you're going that far, might as well remove the int declaration and pass it straight into the createwall function. Only real pros know about minimising lines of code whilst sacrificing readability.  WTF
Logged

Rat Casket
Level 10
*****


i can do what i want


View Profile WWW
« Reply #52 on: September 26, 2013, 06:53:41 AM »

I think he speaks spanish.
Logged

vittorioromeo
Level 2
**



View Profile WWW
« Reply #53 on: September 26, 2013, 07:00:11 AM »



If you're going that far, might as well remove the int declaration and pass it straight into the createwall function. Only real pros know about minimising lines of code whilst sacrificing readability.  WTF

Haha no, I was just kidding. Source code is for humans.
I stopped at:




What language is this!?

Visual Basic.NET++11
Logged

vittorioromeo
Level 2
**



View Profile WWW
« Reply #54 on: September 27, 2013, 07:31:17 AM »

Today I spent all day on a weapon system.
It sucks, it introduces unnecessary complexity and makes heavy use of capturing lambdas... but:

* Creating new weapons is very easy
* Weapons have a lot of flexibility (it's not a bunch of parameters, it's a lambda that can do anything)
* Thanks to value semantics, I can have copies of weapons with slight variations
* I can easily give an enemy, the player or a turret a certain weapon both at compile-time and run-time and it will work

Example code explained:


1. Notice the return type, `OBWpn`. It's not a reference or a pointer, it's a copy. This allows, for example, to have an enemy use a special version of an existing weapon.
2. For simple weapons, such as the first one (`EPlasmaBulletGun`), the `onShoot` delegate does not capture anything. Non-capturing lambdas with Don Clugston's fast delegates get inlined by clang++ as a normal function call. Yes. (g++ does a worse job, but it's still faster than capturing lambdas).
3. Every projectile the weapon creates goes through `mWpn.shotProjectile`, which fires a callback other entities can attach to. So I could have a "piercing bullets power-up", that, when active, attaches to `OBWpn::onShotProjectile(OBCProjectile&)` delegate, and sets every spawned projectile as piercing.
4. In case of a power-up that modifies the way the weapon shoots, and not projectile parameters, there is a similar delegate in `OBCWpnController`, a component attached to entities with guns that controls fire delay and contains a `OBWpn` object.

So, let's analyze `createEPlasmaGun(int mFanCount)`.

The first instruction creates a `OBWpn` object called result, with parameters:
* Shoot delay: 75.f
* Projectile damage: 1.f
* Projectile speed: 260.f
* Sound ID: "Sounds/machineGun.wav"

The second instruction subscribes (`+=`) a capturing lambda to the weapon's `onShoot` delegate. Inside the lambda we tell the weapon to create `PJStarPlasma` projectiles and fire them in a fan-like formation. When the shots have been fired, we adjust their speed so that "outer" shoots are slower.

Then we return the weapon to the caller.



It works, but it's very messy. Does anyone have any suggestion on how to improve it?
Logged

vittorioromeo
Level 2
**



View Profile WWW
« Reply #55 on: September 28, 2013, 06:34:03 AM »

new video - particle blendmodes, ai changes, plasma bombs, wip level editor




In the video:
* Particle systems now can have a specific blendmode: addition works great for plasma effects!
* Minor ai changes: when an enemy doesn't see you, he moves around to find a trajectory
* Plasma bombs: new projectile type that explodes into plasma bolts
* wip level editor: just started creating a level editor that saves/loads from JSON
Logged

vittorioromeo
Level 2
**



View Profile WWW
« Reply #56 on: September 29, 2013, 06:01:42 AM »

new video - fully working level editor




In the video:
* Level saving/loading: levels created in the editor are now playable
* Simple editor mouse controls: mousewheel + modifiers to change brush size, rotation and tile types
* Construction and gameplay of two example levels
Logged

Udderdude
Level 10
*****


View Profile WWW
« Reply #57 on: September 29, 2013, 06:03:39 AM »

Nice level editor, I should make one someday .. but I'm still doing my levels in Editpad ..

 Epileptic
Logged
Quarry
Level 10
*****


View Profile
« Reply #58 on: September 29, 2013, 06:17:34 AM »

Ever thought of MP?
Logged
vittorioromeo
Level 2
**



View Profile WWW
« Reply #59 on: September 29, 2013, 06:19:15 AM »

Ever thought of MP?


Local MP will probably be implemented after release.
I would love internet/LAN MP too, but the most complex networking-ish thing I coded is a UDP chatroom... it would be very hard for me to code. (The game is open-source, though, and contributions are appreciated! Tongue)
Logged

Pages: 1 2 [3] 4 5
Print
Jump to:  

Theme orange-lt created by panic