Jump to content
IGNORED

This is my first game using intybasic: RunnerZ


JosueCom

Recommended Posts

The modulus operator isn't so fast in IntyBASIC because it's implemented using repetitive substraction.

 

As your #univclock variable increases, the modulus operator takes longer in special for smaller modulus like 3.

 

I would suggest you to use powers of two for modulus.

  • Like 2
Link to comment
Share on other sites

I suspect the modulo operations you're using become slower and slower as #univclock increases. There is no "divide" or "multiply" instruction on the machine, and so the cost of those operations changes as values get larger.

 

If you compile with the --jlp switch, it'll use an external hardware accelerator. (This accelerator is built into the LTO Flash cartridge, and supported in jzIntv. It's also available on my JLP cartridge boards.)

 

Alternately, if you have values that just increment modulo some value, you're better off dedicating some small 8 bit variables to those values and doing an explicit increment and test.

 

That is, rather than writing:

.

(#univclock % (7-dificulty))

.

Have some other variable that increments 0 .. 6-dificulty. For example, if I called it 'diff_phase': (Short for "difficulty phase'.)

.

diff_phase = diff_phase + 1
if diff_phase = (7-dificulty) then diff_phase = 0

.

This one will also get slower and slower and slower:

.

#univclock%3

.

I'd replace that with, say, "move_phase" (short for movement phase):

.

move_phase = move_phase + 1
if move_phase = 3 then move_phase = 0

.

Some of the modulos may be OK. I believe IntyBASIC will replace modulo with a bitwise AND if you're computing modulo a power of 2. So %8 ends up being the same as AND 7. You can double check by looking at the compiler output. Your BASIC source code will be interlisted with the corresponding assembly, making it easy to find what your code expands into.

 

 

Other minor things:

.

RAND%3

.

is better written as

.

RAND(3)

.

It might not be obvious from the generated assembly, but the latter is much faster. The RAND%3 generates a loop that repeatedly subtracts 3 from the random seed. That could iterate many, many times. The RAND(3) calls "qs_mpy8". That performs multiplication via the quarter square method, and takes ~50 cycles. Compared to the repeated subtract method, it's actually much faster.

.

    ;[2] x = RAND%3
    SRCFILE "r.bas",2
    MVI _rand,R0
T1:
    SUBI #3,R0
    BC T1
    ADDI #3,R0
    MVO R0,V1
    ;[3] y = RAND(3)
    SRCFILE "r.bas",3
    MVII #3,R0
    MVI _rand,R1
    CALL qs_mpy8
    SWAP R0
    ANDI #255,R0
    MVO R0,V2

.

This comment also applies to your other calls to RAND.

 

You also need to be a little careful with RAND: RAND only updates once per frame. If you need distinct random numbers, use RANDOM() instead. The range on both is limited 0..255, so if you need larger random numbers, you need to do something different. (At first, I thought you might have an issue in chooseObject, but on closer inspection, you don't.)

 

This sets all the array values to 0. I suspect you did not want to /100 here. You do the right thing in determinelevel, so I suspect this is stale code?

.

percentage(0) = 48/100
percentage(1) = 23/100
percentage(2) = 23/100
percentage(3) = 4/100
percentage(4) = 2/100

.

If you make the percentages cumulative, you can avoid the awkward math in chooseObject. That is, you could do something like this:

.

percentage[0] = 48
percentage[1] = 23 + percentage[0]
percentage[2] = 23 + percentage[1]
percentage[3] = 4 + percentage[2]
percentage[4] = 2 + percentage[3]

.

Then your chooseObject routine can avoid all that addition:

.

chooseObject: procedure
	chance = RANDOM(percentage(4))
	if chance < percentage(0) then 'nothing chances
		chance = 0
	elseif chance < percentage(1) then 'rock chances
		chance = 1
	elseif chance < percentage(2) then 'coin chances
		chance = 2
	elseif chance < percentage(3) then 'apple chances
		chance = 3
	else 'Random powerup
		chance = RANDOM(3) + 4 'Powerup
	end if

	return
end

.

I'm not sure 'percentage' is a great name for that variable. cum_obj_weight (cumulative object weight) is perhaps more descriptive.

 

If you can make the weights always sum to 128 or 256, you can make this even more efficient by eliminating percentage(4) and replacing RANDOM(percentage(4)) with RANDOM(256). The computation for that is more efficient. Basically, you'll just scale all your weights upwards by 2.56, and round creatively so they sum to 256.

 

Try tweaking those things, and see where you end up. :-)

Edited by intvnut
  • Like 3
Link to comment
Share on other sites

Good concept! it does need a few tweaks. It reminds me of Antarctic Adventure (Kojima was co-designer of sequel, Penguin adventure), and also somewhat of 80's Casio watch racing games, GD8, and GT6. I think 2d videogames are a great as an introduction to programming. There is a lot of material in the forums: great code, tutorials, documentation, tools, and advanced techniques.

 

I viewed the source code... very few comments. Some should've constants, for example, const ROCK=1. Code is very well organized and readable, but, I still prefer reading 1 comment than mentally interpreting 2 lines of code.

About gameplay, the 1st level starts OK, but later levels are too slow and too easy. The animated road can be white, text shouldn't flash, I recommend more obstacles, player should bump/shake when losing a life, and there should be more variety of object placement.

  • Like 1
Link to comment
Share on other sites

Thank you for the feedback. I will add more comments. I was not able to work on the game much do to the finals exams. I will work on it as soon as possible.

 

I do not have more cards available. So, I can only change the colors of the ones I have. I am going to work on a new version with more functionalities. I am also working on the animation with the previous suggestions. What do you suggest to make the levels harder?

 

Good concept! it does need a few tweaks. It reminds me of Antarctic Adventure (Kojima was co-designer of sequel, Penguin adventure), and also somewhat of 80's Casio watch racing games, GD8, and GT6. I think 2d videogames are a great as an introduction to programming. There is a lot of material in the forums: great code, tutorials, documentation, tools, and advanced techniques.

 

I viewed the source code... very few comments. Some should've constants, for example, const ROCK=1. Code is very well organized and readable, but, I still prefer reading 1 comment than mentally interpreting 2 lines of code.

About gameplay, the 1st level starts OK, but later levels are too slow and too easy. The animated road can be white, text shouldn't flash, I recommend more obstacles, player should bump/shake when losing a life, and there should be more variety of object placement.

Link to comment
Share on other sites

I have updated the game. This is version 1 of it. The GitHub link is the same as above: https://github.com/JosueCom/RUNNERZ

runnerZ.rom

 

Things that the player can do (cont1):

 

- jump = up button

- move to the right = right button

- move to the left = left button

- pause = pause key (have not test it because I could not find the key)

Edited by JosueCom
  • Like 3
Link to comment
Share on other sites

First cut at some title screen music

 

 

Mode 0,1,0,1,0
Wait
Border 1,0
Scroll 4,4,0
For borderNew=0 to 200 Step 20 : Poke $200+borderNew, $2000: Poke $213+borderNew, $2000 : Next borderNew
Wait
Wait
Print At 21 Color 7 , "runnerz01"
Print At 141 Color 5 , "Restart: Top side"
Print At 161 Color 6 , "Exit: Bottom side"



ecsCheck = peek($4000)
Poke $4000 , ecsCheck + 1
If Peek($4000) = ecsCheck + 1 then
Print At 81 Color 4 , "(PSG+ECS) "
Else
Print At 81 Color 4 , "(PSG only)"
End If

Wait
Play Full
Wait
Play runnerz01
Wait
Goto PlayLoop


PlayLoop:
Wait
If Cont.B0 Then Wait : Play Off : Wait : Play runnerz01
If Cont.B1 Then Goto ExitThis
If Cont.B2 Then Goto ExitThis
Wait
Goto PlayLoop

ExitThis:
Wait
Print At 213 Color (Rand and 7) , "Bye."
For spinWait = 0 to 5
Wait
Next
Play Off



ASM ORG $A000


runnerz01:

Data 5

Music - , - , -
Music - , - , -
Music D6W , - , -
Music S , - , -
Music F6 , - , -
Music D6 , - , -
Music S , - , -
Music S , - , -
Music G6 , A4#Y , G4Y
Music S , S , S
Music S , S , S
Music S , A4 , F4
Music S , S , S
Music S , S , S
Music S , A4# , G4
Music S , S , S
Music S , S , S
Music S , S , S
Music F6 , S , S
Music S , S , S
Music S , S , S
Music G6 , S , S
Music S , S , S
Music S , S , S
Music D6 , S , G4
Music S , S , S
Music S , S , S
Music S , A4 , F4
Music S , S , S
Music S , S , S
Music S , A4# , G4
Music S , S , S
Music S , S , S
Music S , S , S
Music C6 , S , S
Music S , S , S
Music S , S , S
Music A5 , S , S
Music S , S , S
Music S , S , S
Music G5 , S , G4
Music S , S , S
Music S , S , S
Music S , A4 , F4
Music S , S , S
Music S , S , S
Music S , A4# , G4
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music S , S , S
Music D6 , G5 , D4#
Music S , S , F4
Music S , S , D4#
Music F6 , A5 , F4
Music S , S , S
Music S , S , F4
Music S , S , S
Music G6 , A5# , F4
Music S , S , G4
Music S , S , S
Music S , S , -
Music S , S , -
Music Stop

 

 

 

The link to the game is https://github.com/JosueCom/RUNNERZ--intellivision_Game. I got introduced to IntyBasic and the forum by my computer science professor in college. I am currently a sophomore. Tell me what you think about it. Good? Bad? I have attached the rom file; attachicon.gifrunnerZ.rom .

Link to comment
Share on other sites

 

I am absolutely curious to know who your Computer Science professor is. He or she must be a most interesting person. :)

 

The professor actually contacted me in order to acquire an LTO Flash! to run the projects with. Sounds really awesome if you ask me. :-)

 

I'll leave it to him to pipe up if he'd like to "out" himself.

 

The course syllabus for the class (if I found the right one) goes roughly: bits, fundamental data types, combinatorial logic, sequential logic, Von Neumann architecture, assembly language, I/O, interpreters, and then compilers. The course appears to have a strong assembly language component with the LC-3 educational architecture.

 

That's quite the tour de force, if you ask me.

  • Like 2
Link to comment
Share on other sites

 

The professor actually contacted me in order to acquire an LTO Flash! to run the projects with. Sounds really awesome if you ask me. :-)

 

I'll leave it to him to pipe up if he'd like to "out" himself.

 

The course syllabus for the class (if I found the right one) goes roughly: bits, fundamental data types, combinatorial logic, sequential logic, Von Neumann architecture, assembly language, I/O, interpreters, and then compilers. The course appears to have a strong assembly language component with the LC-3 educational architecture.

 

That's quite the tour de force, if you ask me.

 

Wow... that is awesome. It almost makes me want to go back to college. Almost. Hehehe...

 

My Computer Science curriculum was heavy on the architecture, hardware, and electronics side (this was the late 80s and early 90s), while the software component was rather bare. It started with Introduction to BASIC for general computer architecture, then Data Structures in Pascal, Structured Programming in Cobol, and a hint of x86 Assembly to introduce Von Neumann architecture. My C programming exposure came from an elective class in the Business Major curriculum ("Programming of Information Systems"; MBAs had a chance at C, CS majors had mostly Pascal and Cobol), and I had to tap the Electrical Engineering curriculum to get a taste of discrete circuits and sequential/combinatorial logic.

 

My schedule was a hodge-podge of courses from many different curricula, taken as elective classes.

 

I hear about syllabi like you mentioned and I get very excited. :)

 

-dZ.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...