Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - tebakutis

Pages: [1]
1
Script / Re: Help Using Timers in Scripted Game Dev?
« on: 2006-11-20, 05:54:20 PM »
This is actually the solution I was able to ferret out by digging through threads, following a link to forums, and following a link from there to more forums. :0 I managed to get a basic timer working in game using the approach of incrementing a player inventory item each frame and basing the timing of functions off that. My only concern would be how much processing power such a mechanism takes up.

I don't see it being a big issue with one timer. However, what if I want two timers running simultaneously? Four? Eight? It seems to me the load on the game engine could get quite heavy given enough use of timers, and though there are cases where you could reuse the same timer, I'm assuming you will have to have some timers running independently in cases where both timers may need to be running at once (for instance, a cooldown on use of a spell PLUS a cooldown on your invincibility buff).

Basically, the incrementing an inventory item approach works (going by 60 = 1 second) but the impact it has on gameplay worries me. How big a hit do you think a game takes from running multiple timers? (which I'm assuming must always be running in the background, as the function to increment them is played in OnAfterMoveSprites).

2
Off-Topic / Re: What's the best 2D game ever created
« on: 2006-11-20, 04:46:20 PM »
What, no one here liked Target: Earth? To this day that's one of my favorite side-scrollers ever, simply because the art was cool, you actually had ALLIES fighting beside you (no more one man vs an army) and I'm a sucker for run-and-gun games.

I mean, the 8th stage had you flying through space fighting other mecha with a backdrop of a giant Earth fleet of ships (probably in the range of 20 or ships including the command ship which was like... 3 screens long) vs a fleet of alien ships (even more ships and a mothership that was 6 screens wide or something) all of whom were firing at each other while their respective mecha fought in their shadows.

Flying through stage 8 with capital ships blasting away on all sides and you, your buddies and the enemy all dogfighting while it goes on is STILL one of my best game experiences in a side-scrolling game... Target: Earth just felt truly epic, especially in that last space battle stage.

3
Script / Help Using Timers in Scripted Game Dev?
« on: 2006-11-20, 04:14:37 PM »
Okay, I must be the biggest noob in existence because I've checked this forum and the Troubleshooting forum and NO ONE has ever asked a question about how to use timers in Gamedev. So, I guess I'll start.

What I need is the basic script to create a timer in Gamedev script, basically so I can do things such as have functions fire after a certain period of time. For instance, having the player switch to an 'invicible' sprite when hit, then switch back to the normal sprite after say, 2 seconds.

I've looked at sample code using timers and I'm just confused as to what is going on here. So, if somebody could just post how to create a basic timer here, I'd be very appreciative.

4
Script / Running a Special Function from Code
« on: 2006-11-16, 05:19:35 PM »
I'm trying to figure out how to run a SpecialFunction created in the 'Special Functions' section of a map using code. Basically, I'd like to trigger the SpecialFunction from the code that runs with the game--I'm doing this to allow the same button to trigger two different special functions, with which SpecialFunction is implemented based on the character's inventory. Here's what I have so far.

Code: [Select]
Option Explicit

Sub Player_OnControllerMove(OldActions, NewActions)

    'The code below transforms the robot to car form
    'and the car to robot form using one button.

    'When the user presses button 1, covert to robot or
    'car form based on if the robot counter is in the
    'player's inventory.

    If ((OldActions And eActionBits.ACTION_BUTTON1) = 0) And _
       ((NewActions And eActionBits.ACTION_BUTTON1) <> 0) Then

       If ProjectObj.GamePlayer.InvQuantityOwned(2) = 1 Then
           'convert player to car
------> I need a line of code here that will trigger the special function that exists in my map.
           'subtract robot counter
           ProjectObj.GamePlayer.InvQuantityOwned(2) = 0
       Else
           'covert player to robot
------> I need a line of code here that will trigger the special function that exists in my map.
           'add robot counter
           ProjectObj.GamePlayer.InvQuantityOwned(2) = 1
       End If

    End If

End Sub


HostObj.SinkObjectEvents ProjectObj.Gameplayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16

Here's additional information that relates to referencing the special functions.

- The map is called 'Roadtest'
- The layer on which the PlayerSprite resides is called 'bg' and is the only layer in the project.
- The SpecialFunctions in question are called 'TransformRobot' and 'TransformCar', and are the first two special functions on the layer.
- There is an item in the Player's inventory called 'RobotCounter' at index 3 which is set to 1 or 0 based on the form the player is in... this determines whether the player transforms from robot to car or car to robot.

So, I need a line of code that will trigger the existing TransformRobot and TransformCar Special Functions. I haven't been able to nail down the exact syntax to reference these, so any help is appreciated.

5
Script / Re: Improving my 'Jump on Enemy's Head' Script
« on: 2006-09-19, 06:28:39 PM »
Eh, nevermind... I figured out what the problem was. I left a Map Interaction in the level from a previous try at this that was setting the JumpAttack number to 0. Took it out and it works fine now!

6
Script / Improving my 'Jump on Enemy's Head' Script
« on: 2006-09-19, 05:22:32 PM »
I'm playing a bit with a game setup to allow me to hurt the player if they touch an enemy, or destroy the same enemy if they jump on it's head. The behavior I wanted to implement had the following characteristics:

- If the player touches an enemy and they are not airborne, they are hurt.
- If the player lands on an enemy after jumping, the enemy is terminated.
- If the player lands on an enemy after falling, the enemy is terminated.

The first thing I did was to create an invisible player inventory item I named 'JumpAttack'. This allowed me to set up simple collision definitions in the Dev Kit... if the player sprite encountered an enemy sprite without JumpAttack in their inventory, they were hurt. If they had JumpAttack in their inventory, the enemy sprite was killed. The player is given an initial quanity of 0 JumpAttack and may have a maximum of 1.

My next step was to implement script that would automatically provide the player with the JumpAttack item if they were falling (which would mean they had either jumped or dropped off a ledge). My solution to this was to add JumpAttack to the player's inventory whenever their downward vertical velocity was active, and remove it otherwise. This was accomplished with the following script (assume this is inserted into a larger batch, I just posted the pertinent sub).

Code: [Select]
Sub Player_OnAfterMoveSprites()

     'The code below detects whether the player is currently falling, which
     'determines whether or not they will kill an enemy if they contact it.
     'If at any time the player's DY value is greater than 0 they are
     'assumed to be falling (in vertical motion down) and will kill any enemy
     'they land on.

     If ProjectObj.GamePlayer.PlayerSprite.DY > 0 Then
          ProjectObj.GamePlayer.InvQuantityOwned(2) = 1
     Else
          ProjectObj.GamePlayer.InvQuantityOwned(2) = 0
     End If

End Sub

In the code sample above, Index 2 refers to the JumpAttack item.


This got most of the results I needed (I can terminate enemies if I land on them after a jump or fall) with a few problems.

- If the player is falling yet is in contact with any solid tile (say sliding down the side of a raised wall) they are not properly credited with the JumpAttack item, even though they are moving downward.
- If the enemy is directly below the player (there is no vertical space between the player and the enemy, such as the enemy standing 32 and the player standing on a 32 wall), and the player drops on the enemy, the JumpAttack item is not added quickly enough to prevent damage (I'm assuming there is no room for the player to gain any sort of vertical velocity in this case).

Anyone have any ideas on how to improve this? I'd like to come up with a good method for killing an enemy whenever a PlayerSprite collides with it while in any downward motion--this is a start, but still has problems whenever the player is touching the side of another tile (even if falling).

Pages: [1]